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
KeyStateTracker
Defined in: key-state-tracker.ts:63
Singleton tracker for currently held keyboard keys.
This class maintains a list of all keys currently being pressed, which is useful for:
- Displaying currently held keys to users
- Custom shortcut recording for rebinding
- Complex chord detection
State Management:
- Uses TanStack Store for reactive state management
- State can be accessed via tracker.store.state when using the class directly
- When using framework adapters (React), use useHeldKeys and useHeldKeyCodes hooks for reactive state
Example#
const tracker = KeyStateTracker.getInstance()
// Access state directly
console.log(tracker.store.state.heldKeys) // ['Control', 'Shift']
// Subscribe to changes with TanStack Store
const unsubscribe = tracker.store.subscribe(() => {
console.log('Currently held:', tracker.store.state.heldKeys)
})
// Check current state
console.log(tracker.getHeldKeys()) // ['Control', 'Shift']
console.log(tracker.isKeyHeld('Control')) // true
// Cleanup
unsubscribe()Properties#
store#
readonly store: Store<KeyStateTrackerState>;Defined in: key-state-tracker.ts:70
The TanStack Store instance containing the tracker state. Use this to subscribe to state changes or access current state.
Methods#
areAllKeysHeld()#
areAllKeysHeld(keys): boolean;Defined in: key-state-tracker.ts:268
Checks if all of the given keys are currently held.
Parameters#
keys#
string[]
Array of key names to check
Returns#
boolean
True if all of the keys are currently held
destroy()#
destroy(): void;Defined in: key-state-tracker.ts:275
Destroys the tracker and removes all listeners.
Returns#
void
getHeldKeys()#
getHeldKeys(): string[];Defined in: key-state-tracker.ts:235
Gets an array of currently held key names.
Returns#
string[]
Array of key names currently being pressed
isAnyKeyHeld()#
isAnyKeyHeld(keys): boolean;Defined in: key-state-tracker.ts:258
Checks if any of the given keys are currently held.
Parameters#
keys#
string[]
Array of key names to check
Returns#
boolean
True if any of the keys are currently held
isKeyHeld()#
isKeyHeld(key): boolean;Defined in: key-state-tracker.ts:245
Checks if a specific key is currently being held.
Parameters#
key#
string
The key name to check (case-insensitive)
Returns#
boolean
True if the key is currently held
getInstance()#
static getInstance(): KeyStateTracker;Defined in: key-state-tracker.ts:85
Gets the singleton instance of KeyStateTracker.
Returns#
KeyStateTracker
resetInstance()#
static resetInstance(): void;Defined in: key-state-tracker.ts:95
Resets the singleton instance. Useful for testing.
Returns#
void