useKeyboardShortcuts

Global shortcuts such as mod+k.

useKeyboardShortcuts({ 'mod+k': handler, '/': handler }, enabled = true)

Global keyboard shortcuts. A combo is modifiers joined with + and a key: mod+k, shift+?, g. mod is Cmd on macOS and Ctrl elsewhere; the other modifiers are ctrl, alt, shift and meta. Combos match exactly, and a shortcut without a modifier is ignored while the user types in a field. A matching shortcut calls preventDefault. `CommandPalette` is usually opened this way.

Try Ctrl/Cmd+K, Shift+? or g. Last: none

API

  • shortcuts{ [combo: string]: (event) => void }

    Handlers by combo. The latest object is always used, so inline handlers are fine.

  • enabledboolean
    Default: true

    Pause the shortcuts.

See also:useKeyboardShortcuts component pageCommandPalette