Defined in: controllers/hotkey-recorder.ts:40
A Lit ReactiveController that records keyboard shortcuts.
Wraps the framework-agnostic HotkeyRecorder class, managing all the complexity of capturing keyboard events, converting them to hotkey strings, and handling edge cases like Escape to cancel or Backspace/Delete to clear.
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}
`
}
}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;new HotkeyRecorderController(_host, _options): HotkeyRecorderController;Defined in: controllers/hotkey-recorder.ts:64
ReactiveControllerHost
The Lit component that owns this controller.
HotkeyRecorderOptions
Configuration options for the recorder.
HotkeyRecorderController
get isRecording(): boolean;get isRecording(): boolean;Defined in: controllers/hotkey-recorder.ts:51
Whether recording is currently active.
boolean
get recordedHotkey(): Hotkey | null;get recordedHotkey(): Hotkey | null;Defined in: controllers/hotkey-recorder.ts:56
The currently recorded hotkey (for live preview).
Hotkey | null
cancelRecording(): void;cancelRecording(): void;Defined in: controllers/hotkey-recorder.ts:117
Cancel recording without saving.
void
hostConnected(): void;hostConnected(): void;Defined in: controllers/hotkey-recorder.ts:73
Subscribes to the recorder store and updates the internal state when changes occur.
void
ReactiveController.hostConnectedReactiveController.hostConnectedhostDisconnected(): void;hostDisconnected(): void;Defined in: controllers/hotkey-recorder.ts:92
Unsubscribes from the recorder store and destroys the recorder instance to prevent memory leaks.
void
ReactiveController.hostDisconnectedReactiveController.hostDisconnectedsetOptions(options): void;setOptions(options): void;Defined in: controllers/hotkey-recorder.ts:101
Updates the recorder options (e.g. callbacks).
Partial<HotkeyRecorderOptions>
void
startRecording(): void;startRecording(): void;Defined in: controllers/hotkey-recorder.ts:107
Start recording a new hotkey.
void
stopRecording(): void;stopRecording(): void;Defined in: controllers/hotkey-recorder.ts:112
Stop recording (same as cancel but without calling onCancel).
void