Skip to content

bind key events (press/release) to functions in rust

License

Notifications You must be signed in to change notification settings

nelsongillo/keyfn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

keyfn

Bind key events (press/release) to functions in rust using xlib.
Supports same key with different modifier. Functions are executed in new threads.

Usage

Add this to your Cargo.toml

[dependencies]
keyfn = "0.2.1"

Example

extern crate keyfn;

use keyfn::*;

fn main(){
    // create new KeyStorage
    let mut storage = KeyStorage::new();

    // Call crtl-a_pressed when Control + a is pressed
    let ctrl_a = KeyBind::new(
        keysym::XK_a,
        vec![Mod::Control],
        Trigger::Pressed,
        ctrl_a_pressed,
    );
    
    // Add KeyBind to storage
    storage.add(ctrl_a);

    // start storage
    storage.start();
}

fn ctrl_a_pressed(){
    println!("Control + A pressed!");
}

About

bind key events (press/release) to functions in rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages