useKeyboard
Binds global keyboard shortcuts and cleans them up on unmount. Single-key shortcuts stay quiet while the user types in a field; ctrl, alt and meta combos and Escape always fire.
Install: pnpm add-composable useKeyboard
Global shortcut
Press Ctrl+K (or Meta+K) to trigger an action.
API
shortcuts(Record<string, (e: KeyboardEvent) => void | boolean>): Combos to handlers: 'ctrl+k', 'shift+/' or '?', 'escape', 'j'. ctrl means Ctrl or ⌘. Return true to preventDefault.enabled(MaybeRefOrGetter<boolean>): Binds while true. Without it, the shortcuts bind on mount.options.allowInInputs(boolean): Fire single-key shortcuts inside text fields too.options.repeat(boolean): Fire again on auto-repeat while the key is held.bind, unbind(() => void): Manual control over the listener.