Hotkey
stable 0.9 kB<HkHotkeyService>Scoped keyboard shortcuts that unbind themselves with the component that registered them, and never fire while the user is typing in a field.
#keyboard#service
Live demo
Running in this page — interact with it.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| sequences | boolean | true | Supports two-key runs such as "g d". |
Methods
bind(keys, handler)(keys: string, handler: () => void) => voidRegisters a shortcut, unbound automatically on destroy.
unbind(keys)(keys: string) => voidRemoves one binding early.
scope(name)(name: string) => HkHotkeyScopeCreates a scope so a dialog can shadow global bindings.
Theming
This one adds no tokens of its own — it renders entirely from the global token layer.
Accessibility
- Never fires while focus is in an input, textarea or select — a shortcut must not eat what someone is typing.
- "mod" resolves to Cmd on macOS and Ctrl elsewhere, so bindings read the same in docs on both.
- Bindings are torn down with their component, which is what keeps a long session from accumulating handlers.