Defined in: controllers/hotkey.ts:75
A Lit ReactiveController that registers a hotkey when the host element is connected and unregisters it when the host is disconnected. The hotkey can be a chord such as 'Mod+S', a sequence such as ['G', 'G'], or an app hotkey from defineAppHotkeys, which uses its custom hotkey from provideAppHotkeys.
Chords accept requireReset; sequences accept timeout. Pass a getter for the hotkey or options to re-read them after each host update.
class MyElement extends LitElement {
private save = new HotkeyController(this, 'Mod+S', () => this.doSave())
private top = new HotkeyController(this, ['G', 'G'], () => this.scrollToTop())
constructor() {
super()
this.addController(this.save)
this.addController(this.top)
}
}new HotkeyController(
host,
hotkey,
callback,
options?): HotkeyController;Defined in: controllers/hotkey.ts:87
ReactiveControllerHost
The Lit component that owns this controller. Add the controller with addController().
MaybeGetter<AppHotkey<string, HotkeyChord | HotkeySequence | null>>
The chord, sequence, or app hotkey to register, or a getter. A getter is read on connection and after host updates.
HotkeyCallback
Called with the host as this.
MaybeGetter<AppHotkeyControllerOptions<AppHotkey<string, HotkeyChord | HotkeySequence | null>>>
Options or a getter. Property getters are read on connection and after host updates.
HotkeyController
new HotkeyController(
host,
hotkey,
callback,
options?): HotkeyController;Defined in: controllers/hotkey.ts:93
ReactiveControllerHost
MaybeGetter<RegisterableHotkey>
HotkeyCallback
MaybeGetter<HotkeyControllerCommonOptions>
HotkeyController
hostConnected(): void;Defined in: controllers/hotkey.ts:109
Registers when connected and a target is available.
void
ReactiveController.hostConnectedhostDisconnected(): void;Defined in: controllers/hotkey.ts:145
Releases registrations when the host disconnects.
void
ReactiveController.hostDisconnectedhostUpdated(): void;Defined in: controllers/hotkey.ts:116
Refreshes options after rendering, when scoped targets are available.
void
ReactiveController.hostUpdated