useHotkey
useHotkey(
combo,handler,options?):void
Defined in: src/hooks/useHotkey/useHotkey.ts:155
Bind a single keyboard combo to a callback.
Combos use the same +-separated string format as MenuBar’s shortcut
prop: "Ctrl+S", "Cmd+Shift+P", "Escape". Modifiers: Ctrl, Cmd
(= Meta), Alt / Option, Shift. Cmd automatically maps to Ctrl on
non-Mac platforms via getPlatform().
The handler reference is stable — passing a fresh inline function on every render is safe and does not re-subscribe the underlying listener.
Parameters
combo
string
handler
(event) => void
options?
UseHotkeyOptions = {}
Returns
void
Example
useHotkey('Ctrl+S', e => save(), { preventDefault: true });useHotkey('Escape', () => setOpen(false));useHotkey('Cmd+K', () => openCommandPalette()); // Cmd on Mac, Ctrl elsewhere