Defined in: controllers/hotkey.ts:80
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())
}T extends AdapterHotkeyInput = AdapterHotkeyInput
new HotkeyController<T>(
host,
hotkey,
callback,
options?
): HotkeyController<T>;Defined in: controllers/hotkey.ts:94
ReactiveControllerHost
The Lit component that owns this controller. The controller adds itself to it.
IfTypeParameter<T, MaybeGetter<T | null | undefined>, KnownHotkey<T, MaybeGetter<T | 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<IfTypeParameter<T, HotkeyCallbackContext, AdapterCallbackContextFor<T>>>
Called with the host as this.
IfTypeParameter<T, MaybeGetter<HotkeyControllerOptions>, MaybeGetter<[T] extends [AppHotkey<string, AppHotkeyBinding>] ? AdapterAppHotkeyOptions<Extract<T, AppHotkey<string, AppHotkeyBinding>>, HotkeyControllerTarget> : AdapterOptionsFor<T, HotkeyControllerTarget>>>
Options or a getter. Property getters are read on connection and after host updates.
HotkeyController<T>
dispose(): void;Defined in: controllers/hotkey.ts:173
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.ts:127
Registers when connected and a target is available.
void
ReactiveController.hostConnectedhostDisconnected(): void;Defined in: controllers/hotkey.ts:162
Releases registrations when the host disconnects.
void
ReactiveController.hostDisconnectedhostUpdated(): void;Defined in: controllers/hotkey.ts:137
Refreshes options after rendering, when scoped targets are available.
void
ReactiveController.hostUpdated