handy-keys
Cross-platform global keyboard shortcuts library for Rust.
Features
- Cross-platform: Works on macOS, Windows, and Linux
- Global hotkeys: Register system-wide keyboard shortcuts
- Hotkey blocking: Registered hotkeys are blocked from reaching other applications
- Modifier-only hotkeys: Support for shortcuts like
Cmd+Shiftwithout a key - String parsing: Parse hotkeys from strings like
"Ctrl+Alt+Space" - Hotkey recording: Low-level keyboard listener for "record a hotkey" UI flows
- Serde support: All types implement
Serialize/Deserialize
Installation
[]
= "0.1"
Quick Start
use ;
Platform Notes
macOS
Requires accessibility permissions. The library provides helpers to check and request access:
use ;
if !check_accessibility
Windows
Uses low-level keyboard hooks. No special permissions required.
Linux
Uses rdev. On Wayland, hotkey blocking may not work due to compositor restrictions.
Modifiers
| Modifier | Aliases |
|---|---|
CMD |
command, meta, super, win |
CTRL |
control |
OPT |
option, alt |
SHIFT |
|
FN |
function (macOS only) |
Recording Hotkeys
For implementing "press a key to set hotkey" UI:
use KeyboardListener;
let listener = new?;
println!;
while let Ok = listener.recv
License
MIT