https://github.com/nelsongillo/keyfn
bind key events (press/release) to functions in rust
https://github.com/nelsongillo/keyfn
keybinder rust xlib
Last synced: about 1 year ago
JSON representation
bind key events (press/release) to functions in rust
- Host: GitHub
- URL: https://github.com/nelsongillo/keyfn
- Owner: nelsongillo
- License: mit
- Created: 2020-03-10T21:36:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-31T16:34:45.000Z (about 6 years ago)
- Last Synced: 2024-10-31T11:52:41.720Z (over 1 year ago)
- Topics: keybinder, rust, xlib
- Language: Rust
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
``` rust
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!");
}
```