Hotkeys API Reference
- HotkeyManager
- getHotkeyManager
- Hotkey
- HotkeyChord
- HotkeySequence
- RegisterableHotkey
- RegisterableHotkeyChord
- RegisterableHotkeySequence
- RawHotkeyChord
- HotkeyOptions
- HotkeyChordOptions
- HotkeySequenceOptions
- HotkeyOptionsFor
- HotkeyRegistrationHandle
- HotkeyRegistrationView
- HotkeyChordRegistrationView
- HotkeySequenceRegistrationView
- toHotkeyRegistrationView
- HotkeyCallback
- HotkeyCallbackContext
- HotkeyChordCallbackContext
- HotkeySequenceCallbackContext
- HotkeyCallbackContextFor
- HotkeyMeta
- ConflictBehavior
- isHotkeySequence
- simplifyHotkey
- createSequenceMatcher
- DEFAULT_SEQUENCE_TIMEOUT
- HotkeysProvider
- useDefaultHotkeysOptions
- useHotkey
- useHotkeyRegistrations
- useHotkeys
- useHotkeysContext
- HotkeysProviderOptions
- HotkeysProviderProps
- UseHotkeyChordOptions
- UseHotkeyCommonOptions
- UseHotkeyDefinition
- UseHotkeyOptions
- UseHotkeyOptionsFor
- UseHotkeySequenceOptions
- UseHotkeyTarget
App Hotkeys API Reference
- defineAppHotkeys
- AppHotkeysStore
- provideAppHotkeys
- publishAppHotkeysStore
- AppHotkey
- AppHotkeyInput
- AppHotkeyOptions
- AppHotkeyListItem
- AppHotkeyStatus
- AppHotkeysState
- AppHotkeysStoreOptions
- CustomHotkeys
- Register
- AppHotkeyId
- RegisteredAppHotkeys
- isAppHotkey
- isCustomHotkey
- resolveAppHotkey
- useAppHotkeyList
- useAppHotkeys
- useCustomHotkeys
- UseCustomHotkeysResult
- UseAppHotkeyOptions
Key hold & held keys API Reference
Hotkey Recorder API Reference
- HotkeyRecorder
- HotkeyRecorderOptions
- HotkeyChordRecorderOptions
- HotkeySequenceRecorderOptions
- HotkeyRecorderState
- HotkeyRecorderCommitKeys
- HotkeyRecorderValidationContext
- HotkeyChordRecorderValidationContext
- HotkeySequenceRecorderValidationContext
- RecorderOptions
- RecorderRejection
- RecorderKeyMode
- findHotkeyConflicts
- HotkeyConflict
- HotkeyConflictOptions
- useHotkeyRecorder
- ReactHotkeyRecorder
Normalization & format API Reference
- formatForDisplay
- FormatDisplayOptions
- DisplayHotkey
- DisplayHotkeyChord
- formatHotkey
- normalizeHotkey
- parseHotkey
- parseKeyboardEvent
- ParsedHotkeyChord
- matchesKeyboardEvent
- areHotkeysEqual
- validateHotkey
- checkHotkey
- assertValidHotkey
- ValidationResult
- ValidatableHotkey
- LogicalKey
- PhysicalKey
- PhysicalKeyCode
- KEY_DISPLAY_SYMBOLS
- PUNCTUATION_KEY_DISPLAY_LABELS
- MAC_MODIFIER_SYMBOLS
- MAC_MODIFIER_LABELS
- WINDOWS_MODIFIER_LABELS
- LINUX_MODIFIER_LABELS
- MODIFIER_ALIASES
- MODIFIER_ORDER
- MODIFIER_KEYS
useHotkeyRecorder
Call Signature#
function useHotkeyRecorder(options): ReactHotkeyRecorder<HotkeyChord>;Defined in: useHotkeyRecorder.ts:68
React hook for recording keyboard shortcuts.
With the default maxSteps: 1, the first valid chord is recorded and onRecord receives a chord such as 'Mod+S'. With a larger maxSteps, each chord adds a step; the recording commits on Enter (unless commitKeys: 'none'), after idleTimeoutMs, or when it reaches maxSteps, and onRecord receives a chord (one step) or a sequence.
Escape cancels. Backspace/Delete removes the last step, or calls onClear when nothing is recorded.
Parameters#
options#
HotkeyChordRecorderOptions
Configuration options for the recorder
Returns#
ReactHotkeyRecorder<HotkeyChord>
The recorder state and controls
Examples#
function ShortcutInput() {
const [shortcut, setShortcut] = useState<Hotkey>('Mod+S')
const recorder = useHotkeyRecorder({ onRecord: setShortcut })
return (
<button onClick={recorder.startRecording}>
{recorder.isRecording ? 'Press keys…' : formatForDisplay(shortcut)}
</button>
)
}const recorder = useHotkeyRecorder({
maxSteps: 3,
onRecord: (hotkey) => setShortcut(hotkey), // 'Mod+S' or ['G', 'H']
})Call Signature#
function useHotkeyRecorder(options): ReactHotkeyRecorder;Defined in: useHotkeyRecorder.ts:71
React hook for recording keyboard shortcuts.
With the default maxSteps: 1, the first valid chord is recorded and onRecord receives a chord such as 'Mod+S'. With a larger maxSteps, each chord adds a step; the recording commits on Enter (unless commitKeys: 'none'), after idleTimeoutMs, or when it reaches maxSteps, and onRecord receives a chord (one step) or a sequence.
Escape cancels. Backspace/Delete removes the last step, or calls onClear when nothing is recorded.
Parameters#
options#
HotkeySequenceRecorderOptions
Configuration options for the recorder
Returns#
The recorder state and controls
Examples#
function ShortcutInput() {
const [shortcut, setShortcut] = useState<Hotkey>('Mod+S')
const recorder = useHotkeyRecorder({ onRecord: setShortcut })
return (
<button onClick={recorder.startRecording}>
{recorder.isRecording ? 'Press keys…' : formatForDisplay(shortcut)}
</button>
)
}const recorder = useHotkeyRecorder({
maxSteps: 3,
onRecord: (hotkey) => setShortcut(hotkey), // 'Mod+S' or ['G', 'H']
})