Docs
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
API Reference
Hotkeys API Reference
Hotkey Sequence API Reference
Key Hold API Reference
Held Keys API Reference
Hotkey Recorder API Reference
Hotkey Sequence Recorder API Reference
Format for Display API Reference
Hotkey Sequence API Reference

useHotkeySequence

Function: useHotkeySequence()

ts
function useHotkeySequence(
   sequence, 
   callback, 
   options): void;

Defined in: useHotkeySequence.ts:73

React hook for registering a keyboard shortcut sequence (Vim-style).

This hook allows you to register multi-key sequences like 'g g' or 'd d' that trigger when the full sequence is pressed within a timeout.

Each step may include modifiers. You can chain the same modifier across steps (e.g. Shift+R then Shift+T). Modifier-only keydown events (Shift, Control, Alt, or Meta pressed alone) are ignored while matching—they do not advance the sequence or reset progress.

Parameters

sequence

HotkeySequence

Array of hotkey strings that form the sequence

callback

HotkeyCallback

Function to call when the sequence is completed

options

UseHotkeySequenceOptions = {}

Options for the sequence behavior. enabled: false keeps the registration (visible in devtools) and only suppresses firing; the hook updates the existing handle instead of unregistering.

Returns

void

Example

tsx
function VimEditor() {
  // 'g g' to go to top
  useHotkeySequence(['G', 'G'], () => {
    scrollToTop()
  })

  // 'd d' to delete line
  useHotkeySequence(['D', 'D'], () => {
    deleteLine()
  })

  // 'd i w' to delete inner word
  useHotkeySequence(['D', 'I', 'W'], () => {
    deleteInnerWord()
  }, { timeout: 500 })

  // Same modifier on consecutive steps (bare Shift between chords is ignored)
  useHotkeySequence(['Shift+R', 'Shift+T'], () => {
    nextAction()
  })

  return <div>...</div>
}