Founding price: $35, then $99 after 23:59 UTC on 4 November, then $99
Get ProRun a callback when a sequence of keys is typed in order, such as g then i or the Konami code, with a timeout between keys.
Derived from this item’s props table, because it declares no controls of its own. This item has no standalone playground, so changes update the code, the share link and the AI prompt.
Use it for Gmail- or GitHub-style two-key navigation ("g" then "i"), command-palette chords, and easter eggs.
Do not use it for single shortcuts or modifier combinations (use useHotkey). Do not use it as the only way to reach a feature.
import { useKeySequence } from "@/hooks/use-key-sequence"useKeySequence(["g", "i"], () => navigate("/inbox"), { timeout: 800 })useKeySequence(sequence: string[], onMatch: () => void, options?): void
| Name / option | Type | Default | Description |
|---|---|---|---|
sequence | string[] | - | event.key values in order, compared ignoring case. |
onMatch | () => void | - | Called when the whole sequence is typed. The newest is used. |
timeout | number | 1000 | Ms allowed between keys before the progress resets. |
enabled | boolean | true | Listen only while true. |
Keys typed in inputs, textareas, selects and editable elements are ignored, and so are presses with Ctrl, Meta or Alt held. A wrong key resets the progress, but it counts as a possible new start.
Single-key shortcuts can conflict with speech input and assistive technology; let people turn them off or remap them (WCAG 2.1.4), and list them in a help dialog.
The hook ships with renderHook tests (use-key-sequence.test.ts) covering its behaviour, cleanup on unmount and server-safe defaults. It is safe to render on the server.