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
- hotkey
- HotkeyController
- HotkeyRegistrationsController
- HotkeyControllerChordOptions
- HotkeyControllerCommonOptions
- HotkeyControllerOptions
- HotkeyControllerOptionsFor
- HotkeyControllerSequenceOptions
- HotkeyControllerTarget
App Hotkeys API Reference
- defineAppHotkeys
- AppHotkeysStore
- provideAppHotkeys
- publishAppHotkeysStore
- AppHotkey
- AppHotkeyInput
- AppHotkeyOptions
- AppHotkeyListItem
- AppHotkeyStatus
- AppHotkeysState
- AppHotkeysStoreOptions
- CustomHotkeys
- Register
- AppHotkeyId
- RegisteredAppHotkeys
- isAppHotkey
- isCustomHotkey
- resolveAppHotkey
- AppHotkeysController
- AppHotkeyControllerOptions
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
- HotkeyRecorderController
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
HotkeyRecorderController
Defined in: controllers/hotkey-recorder.ts:48
A Lit ReactiveController that records keyboard shortcuts.
With the default maxSteps: 1, the first valid chord is recorded. With a larger maxSteps, each chord adds a step; the recording commits on Enter (unless commitKeys: 'none'), after idleTimeoutMs, or at maxSteps, and onRecord receives a chord (one step) or a sequence. Escape cancels; Backspace/Delete removes the last step or clears.
Example#
class ShortcutSettings extends LitElement {
private recorder = new HotkeyRecorderController(this, {
onRecord: (hotkey) => {
this.shortcut = hotkey
this.requestUpdate()
},
onCancel: () => {
console.log('Recording cancelled')
},
})
private shortcut: Hotkey | null = null
render() {
return html`
<button @click=${() => this.recorder.startRecording()}>
${this.recorder.isRecording ? 'Recording...' : 'Edit Shortcut'}
</button>
${this.recorder.recordedHotkey
? html`<div>Recording: ${this.recorder.recordedHotkey}</div>`
: nothing}
`
}
}Implements#
- ReactiveController
Constructors#
Constructor#
new HotkeyRecorderController(host, options): HotkeyRecorderController;Defined in: controllers/hotkey-recorder.ts:80
Parameters#
host#
ReactiveControllerHost
The Lit component that owns this controller.
options#
HotkeyChordRecorderOptions
Options or a getter, read during recording.
Returns#
HotkeyRecorderController
Constructor#
new HotkeyRecorderController(host, options): HotkeyRecorderController;Defined in: controllers/hotkey-recorder.ts:81
Parameters#
host#
ReactiveControllerHost
options#
HotkeySequenceRecorderOptions
Returns#
HotkeyRecorderController
Constructor#
new HotkeyRecorderController(host, options): HotkeyRecorderController;Defined in: controllers/hotkey-recorder.ts:88
Parameters#
host#
ReactiveControllerHost
options#
() => HotkeySequenceRecorderOptions
Returns#
HotkeyRecorderController
Constructor#
new HotkeyRecorderController(host, options): HotkeyRecorderController;Defined in: controllers/hotkey-recorder.ts:92
Parameters#
host#
ReactiveControllerHost
options#
() => HotkeyChordRecorderOptions
Returns#
HotkeyRecorderController
Constructor#
new HotkeyRecorderController(host, options): HotkeyRecorderController;Defined in: controllers/hotkey-recorder.ts:96
Parameters#
host#
ReactiveControllerHost
options#
() => HotkeyRecorderOptions
Returns#
HotkeyRecorderController
Accessors#
isRecording#
Get Signature#
get isRecording(): boolean;Defined in: controllers/hotkey-recorder.ts:62
Whether recording is currently active.
Returns#
boolean
recordedHotkey#
Get Signature#
get recordedHotkey(): Hotkey | null;Defined in: controllers/hotkey-recorder.ts:67
The last committed hotkey: a chord, or a sequence of two or more steps.
Returns#
Hotkey | null
steps#
Get Signature#
get steps(): HotkeySequence;Defined in: controllers/hotkey-recorder.ts:72
Chords recorded so far in a multi-step recording (for live preview).
Returns#
HotkeySequence
Methods#
cancelRecording()#
cancelRecording(): void;Defined in: controllers/hotkey-recorder.ts:167
Cancel recording without saving.
Returns#
void
commitRecording()#
commitRecording(): void;Defined in: controllers/hotkey-recorder.ts:172
Commit the recorded steps now (multi-step recordings).
Returns#
void
hostConnected()#
hostConnected(): void;Defined in: controllers/hotkey-recorder.ts:118
Subscribes to the recorder store and updates the internal state when changes occur.
Returns#
void
Implementation of#
ReactiveController.hostConnectedhostDisconnected()#
hostDisconnected(): void;Defined in: controllers/hotkey-recorder.ts:139
Unsubscribes from the recorder store and destroys the recorder instance to prevent memory leaks.
Returns#
void
Implementation of#
ReactiveController.hostDisconnectedsetOptions()#
setOptions(options): void;Defined in: controllers/hotkey-recorder.ts:149
Updates the recorder options (e.g. callbacks).
Parameters#
options#
Partial<HotkeyRecorderOptions>
Returns#
void
startRecording()#
startRecording(): void;Defined in: controllers/hotkey-recorder.ts:157
Start recording a new hotkey.
Returns#
void
stopRecording()#
stopRecording(): void;Defined in: controllers/hotkey-recorder.ts:162
Stop recording (same as cancel but without calling onCancel).
Returns#
void