Crates.io | keyfn |
lib.rs | keyfn |
version | 0.2.1 |
source | src |
created_at | 2020-03-20 12:07:00.565447 |
updated_at | 2020-03-31 16:35:08.906642 |
description | call function on keypress/release |
homepage | https://github.com/einzigartigername/keyfn |
repository | https://github.com/einzigartigername/keyfn |
max_upload_size | |
id | 220684 |
size | 10,856 |
Bind key events (press/release) to functions in rust using xlib.
Supports same key with different modifier. Functions are executed in new threads.
Add this to your Cargo.toml
[dependencies]
keyfn = "0.2.1"
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!");
}