bind_all/bind_all.rs
1use inputbot::{KeybdKey, MouseButton};
2
3/// This example demonstrates binding all of the keyboard keys and mouse buttons to a
4/// simple function. The function prints the key or button name that was pressed.
5
6fn main() {
7 // Bind all keys to a common callback event.
8 KeybdKey::bind_all(|event| {
9 match inputbot::from_keybd_key(event) {
10 Some(c) => println!("{c}"),
11 None => println!("Unregistered Key"),
12 };
13 });
14
15 // Bind all mouse buttons to a common callback event.
16 MouseButton::bind_all(|event| {
17 println!("{:?}", event);
18 });
19
20 // Call this to start listening for bound inputs.
21 inputbot::handle_input_events();
22}