Crates.io | win-hotkey |
lib.rs | win-hotkey |
version | 0.1.5 |
source | src |
created_at | 2024-12-01 06:58:58.920163 |
updated_at | 2024-12-03 22:47:06.933072 |
description | A lightweight, thread-safe Rust library for managing system-wide hotkeys on Windows, with high-level abstractions and customizable callbacks. |
homepage | https://github.com/0xJWLabs/win-hotkey |
repository | https://github.com/0xJWLabs/win-hotkey |
max_upload_size | |
id | 1467253 |
size | 69,251 |
win-hotkey
is a lightweight and opinionated Rust crate designed for handling system-wide hotkeys on Windows. It provides an easy-to-use abstraction over the Windows API, enabling thread-safe hotkey registration and callback execution.
Alt + A
)VK_*
) and Modifier Keys (MOD_*
).VirtualKey
) and modifiers keys (ModifiersKey
) from human-readable strings.HotkeyManager
instance.VirtualKey
, one or more ModifiersKey
s, and a callback.use win_hotkey::keys::{ModifiersKey, VirtualKey};
use win_hotkey::{HotkeyManager, HotkeyManagerImpl};
fn main() {
let mut hkm = HotkeyManager::new();
hkm.register(VirtualKey::A, &[ModifiersKey::Alt], || {
println!("Hotkey ALT + A was pressed");
})
.unwrap();
hkm.event_loop();
}
Windows hotkey events must be registered and unregistered on the same thread. This limitation makes traditional multi-threaded hotkey management cumbersome.
win-hotkey
provides two hotkey manager implementations:
single_thread::HotkeyManager
)thread_safe::HotkeyManager
) (Default)With the thread_safe
feature enabled (default), the crate automatically provides the thread-safe implementation.
This project is licensed under the MIT License
See the LICENSE
file for details