15 releases
0.2.1 | Dec 6, 2022 |
---|---|
0.2.0 | May 13, 2022 |
0.1.12 | Jan 2, 2022 |
0.1.11 | Oct 7, 2021 |
0.1.1 | Jul 31, 2021 |
#1887 in Hardware support
Used in hookmap
44KB
1K
SLoC
hookmap-core
A core library of hookmap
This library provides input simulation and global hooks for keyboard and mouse.
Supported OS
- Windows 10
Eample
use hookmap_core::{button::Button, event::Event, mouse};
fn main() {
let rx = hookmap_core::install_hook();
while let Ok((event, native_handler)) = rx.recv() {
match event {
Event::Button(event) => {
native_handler.dispatch();
match event.target {
Button::RightArrow => println!("Left"),
Button::UpArrow => println!("Up"),
Button::LeftArrow => println!("Right"),
Button::DownArrow => println!("Down"),
_ => {}
};
}
Event::Cursor(e) => {
native_handler.block();
// Reverses mouse cursor movement
let (dx, dy) = e.delta;
mouse::move_relative(-dx, -dy);
}
Event::Wheel(e) => {
native_handler.dispatch();
println!("delta: {}", e.delta);
}
}
}
}
Dependencies
~1–38MB
~561K SLoC