Hotkeys API Reference
- HotkeyManager
- getHotkeyManager
- HotkeyScopesState
- Hotkey
- HotkeyChord
- HotkeySequence
- RegisterableHotkey
- RegisterableHotkeyChord
- RegisterableHotkeySequence
- RawHotkeyChord
- HotkeyOptions
- HotkeyChordOptions
- HotkeySequenceOptions
- HotkeyOptionsFor
- HotkeyRegistrationHandle
- HotkeyRegistrationView
- HotkeyChordRegistrationView
- HotkeySequenceRegistrationView
- HotkeyRegistrationStatus
- toHotkeyRegistrationView
- HotkeyCallback
- HotkeyCallbackContext
- HotkeyChordCallbackContext
- HotkeySequenceCallbackContext
- HotkeyCallbackContextFor
- HotkeyMeta
- ConflictBehavior
- isHotkeySequence
- simplifyHotkey
- createSequenceMatcher
- DEFAULT_SEQUENCE_TIMEOUT
- HotkeysProvider
- useDefaultHotkeysOptions
- useFormatForDisplay
- useHotkey
- useHotkeyRegistrations
- useHotkeyScopesState
- 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
- detectPlatform
- HotkeyPlatform
- 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
matchesKeyboardEvent
function matchesKeyboardEvent(
event,
chord,
platform?
): boolean;Defined in: match.ts:52
Checks if a KeyboardEvent matches a hotkey.
Physical bindings such as Mod+[KeyS] match event.code exactly. Logical bindings match event.key, the character the key types on the user's keyboard layout. Letters match without regard to case, and Shift that typed a symbol, such as ?, does not need to be written.
When event.key cannot name the shortcut, the key's conventional position (event.code) stands in. That covers non-Latin letters, dead keys, the digit row, symbols typed with Shift, and what macOS Option types. With Option held on macOS, the letter comes from the keycap (event.keyCode) when the browser reports one. A named key such as End and a character typed with AltGr match only as themselves, and so does an ASCII letter outside the digit row. An 'Unidentified' key falls back to its position, except on letter and numpad keys.
Turkish ı is its own letter: an ı binding never fires on the i key, but I fires on the ı key. Keys pressed while an input method editor is composing match nothing.
Parameters#
event#
KeyboardEvent
The KeyboardEvent to check
chord#
| HotkeyChord | ParsedHotkeyChord
The chord string or parsed chord to match against
platform?#
"mac" | "windows" | "linux" = ...
The target platform for resolving 'Mod' (defaults to auto-detection)
Returns#
boolean
True if the event matches the chord
Example#
document.addEventListener('keydown', (event) => {
if (matchesKeyboardEvent(event, 'Mod+S')) {
event.preventDefault()
handleSave()
}
})