Defined in: controllers/hotkey.ts:76
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:88
ReactiveControllerHost
The Lit component that owns this controller. Add the controller with addController().
MaybeGetter< | AppHotkey<string, HotkeyChord | HotkeySequence | null> | null | undefined>
The chord, sequence, or app hotkey to register, or a getter. A getter is read on connection and after host updates. undefined, null, or '' registers nothing, for an optional shortcut.
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:94
ReactiveControllerHost
MaybeGetter<RegisterableHotkey | null | undefined>
HotkeyCallback
MaybeGetter<HotkeyControllerCommonOptions>
HotkeyController
hostConnected(): void;Defined in: controllers/hotkey.ts:112
Registers when connected and a target is available.
void
ReactiveController.hostConnectedhostDisconnected(): void;Defined in: controllers/hotkey.ts:150
Releases registrations when the host disconnects.
void
ReactiveController.hostDisconnectedhostUpdated(): void;Defined in: controllers/hotkey.ts:121
Refreshes options after rendering, when scoped targets are available.
void
ReactiveController.hostUpdated