Docs
CodeRabbit
Cloudflare
Railway
AG Grid
Clerk
OpenRouter
WorkOS
SerpAPI
Netlify
Electric
Prisma
Unkey
Sentry
CodeRabbit
Cloudflare
Railway
AG Grid
Clerk
OpenRouter
WorkOS
SerpAPI
Netlify
Electric
Prisma
Unkey
Sentry
API Reference
Hotkeys API Reference
Hotkey Sequence API Reference
Key hold & held keys API Reference
Hotkey Recorder API Reference
Hotkey Sequence Recorder API Reference
Normalization & format API Reference
Hotkey Sequence API Reference

useHotkeySequences

Function: useHotkeySequences()

ts
function useHotkeySequences(definitions, commonOptions): void;
function useHotkeySequences(definitions, commonOptions): void;

Defined in: useHotkeySequences.ts:68

React hook for registering multiple keyboard shortcut sequences at once (Vim-style).

Uses the singleton SequenceManager. Accepts a dynamic array of definitions so you can register variable-length lists without violating the rules of hooks.

Options are merged in this order: HotkeysProvider defaults < commonOptions < per-definition options

Callbacks and options are synced on every render to avoid stale closures.

Definitions with an empty are skipped (no registration).

Parameters

definitions

[]

Array of sequence definitions to register

commonOptions

=

Shared options applied to all sequences (overridden by per-definition options). Per-row still registers that sequence: suppresses execution only (the row stays in the store and appears in TanStack Hotkeys devtools). Toggling updates the existing handle via (no unregister/re-register churn).

Returns

Examples

tsx
function VimPalette() {
  useHotkeySequences([
    { sequence: ['G', 'G'], callback: () => scrollToTop() },
    { sequence: ['D', 'D'], callback: () => deleteLine() },
    { sequence: ['C', 'I', 'W'], callback: () => changeInnerWord(), options: { timeout: 500 } },
  ])
}
function VimPalette() {
  useHotkeySequences([
    { sequence: ['G', 'G'], callback: () => scrollToTop() },
    { sequence: ['D', 'D'], callback: () => deleteLine() },
    { sequence: ['C', 'I', 'W'], callback: () => changeInnerWord(), options: { timeout: 500 } },
  ])
}
tsx
function DynamicSequences({ items }) {
  useHotkeySequences(
    items.map((item) => ({
      sequence: item.chords,
      callback: item.action,
      options: { enabled: item.enabled },
    })),
    { preventDefault: true },
  )
}
function DynamicSequences({ items }) {
  useHotkeySequences(
    items.map((item) => ({
      sequence: item.chords,
      callback: item.action,
      options: { enabled: item.enabled },
    })),
    { preventDefault: true },
  )
}