Hotkeys API Reference
- HotkeyManager
- getHotkeyManager
- Hotkey
- HotkeyChord
- HotkeySequence
- RegisterableHotkey
- RegisterableHotkeyChord
- RegisterableHotkeySequence
- RawHotkeyChord
- HotkeyOptions
- HotkeyChordOptions
- HotkeySequenceOptions
- HotkeyOptionsFor
- HotkeyRegistrationHandle
- HotkeyRegistrationView
- HotkeyChordRegistrationView
- HotkeySequenceRegistrationView
- toHotkeyRegistrationView
- HotkeyCallback
- HotkeyCallbackContext
- HotkeyChordCallbackContext
- HotkeySequenceCallbackContext
- HotkeyCallbackContextFor
- HotkeyMeta
- ConflictBehavior
- isHotkeySequence
- simplifyHotkey
- createSequenceMatcher
- DEFAULT_SEQUENCE_TIMEOUT
- hotkey
- HotkeyController
- HotkeyRegistrationsController
- HotkeyControllerChordOptions
- HotkeyControllerCommonOptions
- HotkeyControllerOptions
- HotkeyControllerOptionsFor
- HotkeyControllerSequenceOptions
- HotkeyControllerTarget
App Hotkeys API Reference
- defineAppHotkeys
- AppHotkeysStore
- provideAppHotkeys
- publishAppHotkeysStore
- AppHotkey
- AppHotkeyInput
- AppHotkeyOptions
- AppHotkeyListItem
- AppHotkeyStatus
- AppHotkeysState
- AppHotkeysStoreOptions
- CustomHotkeys
- Register
- AppHotkeyId
- RegisteredAppHotkeys
- isAppHotkey
- isCustomHotkey
- resolveAppHotkey
- AppHotkeysController
- AppHotkeyControllerOptions
Key hold & held keys API Reference
Hotkey Recorder API Reference
- HotkeyRecorder
- HotkeyRecorderOptions
- HotkeyChordRecorderOptions
- HotkeySequenceRecorderOptions
- HotkeyRecorderState
- HotkeyRecorderCommitKeys
- HotkeyRecorderValidationContext
- HotkeyChordRecorderValidationContext
- HotkeySequenceRecorderValidationContext
- RecorderOptions
- RecorderRejection
- RecorderKeyMode
- findHotkeyConflicts
- HotkeyConflict
- HotkeyConflictOptions
- HotkeyRecorderController
Normalization & format API Reference
- formatForDisplay
- FormatDisplayOptions
- DisplayHotkey
- DisplayHotkeyChord
- formatHotkey
- normalizeHotkey
- parseHotkey
- parseKeyboardEvent
- ParsedHotkeyChord
- matchesKeyboardEvent
- areHotkeysEqual
- validateHotkey
- checkHotkey
- assertValidHotkey
- ValidationResult
- ValidatableHotkey
- LogicalKey
- PhysicalKey
- PhysicalKeyCode
- KEY_DISPLAY_SYMBOLS
- PUNCTUATION_KEY_DISPLAY_LABELS
- MAC_MODIFIER_SYMBOLS
- MAC_MODIFIER_LABELS
- WINDOWS_MODIFIER_LABELS
- LINUX_MODIFIER_LABELS
- MODIFIER_ALIASES
- MODIFIER_ORDER
- MODIFIER_KEYS
HotkeyController
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.
Example#
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)
}
}Implements#
- ReactiveController
Constructors#
Constructor#
new HotkeyController(
host,
hotkey,
callback,
options?): HotkeyController;Defined in: controllers/hotkey.ts:87
Parameters#
host#
ReactiveControllerHost
The Lit component that owns this controller. Add the controller with addController().
hotkey#
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.
callback#
HotkeyCallback
Called with the host as this.
options?#
MaybeGetter<AppHotkeyControllerOptions<AppHotkey<string, HotkeyChord | HotkeySequence | null>>>
Options or a getter. Property getters are read on connection and after host updates.
Returns#
HotkeyController
Constructor#
new HotkeyController(
host,
hotkey,
callback,
options?): HotkeyController;Defined in: controllers/hotkey.ts:93
Parameters#
host#
ReactiveControllerHost
hotkey#
MaybeGetter<RegisterableHotkey>
callback#
HotkeyCallback
options?#
MaybeGetter<HotkeyControllerCommonOptions>
Returns#
HotkeyController
Methods#
hostConnected()#
hostConnected(): void;Defined in: controllers/hotkey.ts:109
Registers when connected and a target is available.
Returns#
void
Implementation of#
ReactiveController.hostConnectedhostDisconnected()#
hostDisconnected(): void;Defined in: controllers/hotkey.ts:145
Releases registrations when the host disconnects.
Returns#
void
Implementation of#
ReactiveController.hostDisconnectedhostUpdated()#
hostUpdated(): void;Defined in: controllers/hotkey.ts:116
Refreshes options after rendering, when scoped targets are available.
Returns#
void
Implementation of#
ReactiveController.hostUpdated