Expand description
Pure-logic hotkey engine.
kbd provides the domain types and matching logic that every hotkey
system needs: key types, modifier tracking, binding matching, layer
stacks, and sequence resolution. It has zero platform dependencies and can
be embedded in any event loop — winit, GPUI, Smithay, a game loop, or a
compositor.
§Quick Start
Register a hotkey, feed key events, and check for matches:
use kbd::prelude::*;
let mut dispatcher = Dispatcher::new();
// Register Ctrl+S as a global binding
let id = dispatcher.register(
Hotkey::new(Key::S).modifier(Modifier::Ctrl),
Action::Suppress,
).unwrap();
// Simulate a key press
let result = dispatcher.process(
&Hotkey::new(Key::S).modifier(Modifier::Ctrl),
KeyTransition::Press,
);
assert!(matches!(result, MatchResult::Matched { .. }));§Feature Flags
| Flag | Default | Effect |
|---|---|---|
serde | off | Adds Serialize/Deserialize to key and hotkey types |
§See Also
kbd-global— threaded manager with message passing and handles- Bridge crates:
kbd-crossterm,kbd-egui,kbd-iced,kbd-tao,kbd-winit
Modules§
- action
- The
Actionenum — what happens when a binding matches. - binding
- The unified binding types — pattern + action + options.
- dispatcher
- Binding dispatcher — finds which binding (if any) matches a key event.
- error
- Error types for hotkey operations.
- hotkey
- Hotkey composition types:
Modifier,Hotkey,HotkeySequence. - introspection
- Introspection types — snapshots of dispatcher state for UI and debugging.
- key
- Physical key type:
Key. - key_
state - Key state tracking — single source of truth for what’s pressed.
- layer
- Layers — named, stackable collections of bindings.
- prelude
- Convenience re-exports for common types.