3个不稳定版本
0.2.1 | 2020年3月31日 |
---|---|
0.2.0 | 2020年3月20日 |
0.1.0 | 2020年3月20日 |
#8 in #xlib
9KB
193 行
keyfn
使用xlib在Rust中将按键事件(按下/释放)绑定到函数。
支持具有不同修饰符的相同按键。函数在新的线程中执行。
用法
将此添加到您的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!");
}
依赖项
~460KB