forked from obv-mikhail/InputBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbind_all.rs
More file actions
22 lines (18 loc) · 690 Bytes
/
bind_all.rs
File metadata and controls
22 lines (18 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use inputbot::{KeybdKey, MouseButton};
/// This example demonstrates binding all of the keyboard keys and mouse buttons to a
/// simple function. The function prints the key or button name that was pressed.
fn main() {
// Bind all keys to a common callback event.
KeybdKey::bind_all(|event| {
match inputbot::from_keybd_key(event) {
Some(c) => println!("{c}"),
None => println!("Unregistered Key"),
};
});
// Bind all mouse buttons to a common callback event.
MouseButton::bind_all(|event| {
println!("{:?}", event);
});
// Call this to start listening for bound inputs.
inputbot::handle_input_events();
}