Defined in: controllers/hotkey-recorder.ts:54
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, and so do Tab and Shift+Tab unless recordTab is set; Backspace/Delete removes the last step or clears.
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}
`
}
}new HotkeyRecorderController(host, options): HotkeyRecorderController;Defined in: controllers/hotkey-recorder.ts:88
ReactiveControllerHost
The Lit component that owns this controller.
HotkeyChordRecorderOptions
Options or a getter, read during recording.
HotkeyRecorderController
new HotkeyRecorderController(host, options): HotkeyRecorderController;Defined in: controllers/hotkey-recorder.ts:89
ReactiveControllerHost
HotkeySequenceRecorderOptions
HotkeyRecorderController
new HotkeyRecorderController(host, options): HotkeyRecorderController;Defined in: controllers/hotkey-recorder.ts:96
ReactiveControllerHost
() => HotkeySequenceRecorderOptions
HotkeyRecorderController
new HotkeyRecorderController(host, options): HotkeyRecorderController;Defined in: controllers/hotkey-recorder.ts:100
ReactiveControllerHost
() => HotkeyChordRecorderOptions
HotkeyRecorderController
new HotkeyRecorderController(host, options): HotkeyRecorderController;Defined in: controllers/hotkey-recorder.ts:104
ReactiveControllerHost
() => HotkeyRecorderOptions
HotkeyRecorderController
get isRecording(): boolean;Defined in: controllers/hotkey-recorder.ts:70
Whether recording is currently active.
boolean
HotkeyRecorderState.isRecordingget recordedHotkey(): Hotkey | null;Defined in: controllers/hotkey-recorder.ts:75
The last committed hotkey: a chord, or a sequence of two or more steps.
Hotkey | null
HotkeyRecorderState.recordedHotkeyget steps(): HotkeySequence;Defined in: controllers/hotkey-recorder.ts:80
Chords recorded so far in a multi-step recording (for live preview).
HotkeySequence
HotkeyRecorderState.stepscancelRecording(): void;Defined in: controllers/hotkey-recorder.ts:185
Cancel recording without saving.
void
HotkeyRecorderActions.cancelRecordingcommitRecording(): void;Defined in: controllers/hotkey-recorder.ts:190
Commit the recorded steps now (multi-step recordings).
void
HotkeyRecorderActions.commitRecordingdispose(): void;Defined in: controllers/hotkey-recorder.ts:161
Releases the controller now and removes it from its host. Use it to remove a controller early: Lit's removeController alone leaves it active.
void
hostConnected(): void;Defined in: controllers/hotkey-recorder.ts:124
Subscribes to the recorder store and updates the internal state when changes occur.
void
ReactiveController.hostConnectedhostDisconnected(): void;Defined in: controllers/hotkey-recorder.ts:148
Unsubscribes from the recorder store and destroys the recorder instance to prevent memory leaks.
void
ReactiveController.hostDisconnectedsetOptions(options): void;Defined in: controllers/hotkey-recorder.ts:167
Updates the recorder options (e.g. callbacks).
Partial<HotkeyRecorderOptions>
void
startRecording(): void;Defined in: controllers/hotkey-recorder.ts:175
Start recording a new hotkey.
void
HotkeyRecorderActions.startRecordingstopRecording(): void;Defined in: controllers/hotkey-recorder.ts:180
Stop recording (same as cancel but without calling onCancel).
void
HotkeyRecorderActions.stopRecording