Skip to content
Entangle UI v0.13.0

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.

string

(event) => void

UseHotkeyOptions = {}

void

useHotkey('Ctrl+S', e => save(), { preventDefault: true });
useHotkey('Escape', () => setOpen(false));
useHotkey('Cmd+K', () => openCommandPalette()); // Cmd on Mac, Ctrl elsewhere