Defined in: controllers/hotkey.ts:70
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())
}new HotkeyController(
host,
hotkey,
callback,
options?): HotkeyController;Defined in: controllers/hotkey.ts:82
ReactiveControllerHost
The Lit component that owns this controller. The controller adds itself to it.
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:88
ReactiveControllerHost
MaybeGetter<RegisterableHotkey | null | undefined>
HotkeyCallback
MaybeGetter<HotkeyControllerCommonOptions>
HotkeyController
hostConnected(): void;Defined in: controllers/hotkey.ts:107
Registers when connected and a target is available.
void
ReactiveController.hostConnectedhostDisconnected(): void;Defined in: controllers/hotkey.ts:146
Releases registrations when the host disconnects.
void
ReactiveController.hostDisconnectedhostUpdated(): void;Defined in: controllers/hotkey.ts:117
Refreshes options after rendering, when scoped targets are available.
void
ReactiveController.hostUpdated