Skip to content

useHotkeys

@astryxdesign/core v0.7.1 · useHotkeys

Parameters ​

NameTypeDefaultDescription
hotkeysMaybeRefOrGetter<readonly Hotkey[]>—Shortcut registrations. A plain array, a ref, or a getter all work; the list is read on each key press. Required.
hotkeys[].keysstring—A "+"-separated combo like "mod+k", "shift+/", "escape". mod is ⌘ on macOS and Ctrl elsewhere. Aliases: esc, space, up, down, left, right, return, and plus for a literal +. Without shift in the combo, the shift state is ignored, so a single letter does not care about case.
hotkeys[].onPress(event: KeyboardEvent) => void—Called when the combo matches, after preventDefault().
hotkeys[].allowInInputsbooleanfalseLets the hotkey fire while typing in an input, textarea, select, or contenteditable region.
hotkeys[].isDisabledbooleanfalseTemporarily disables this entry without removing the listener.

Returns ​

NameTypeDescription
—voidNothing is returned. The window listener is removed when the component unmounts.