Defined in: controllers/held-key-codes.ts:27
A Lit ReactiveController that tracks all currently held key names to their physical event.code values.
Subscribes to the global KeyStateTracker and triggers host updates whenever keys are pressed or released.
class KeyDisplay extends LitElement {
private heldKeyCodes = new HeldKeyCodesController(this)
render() {
const heldCodes = Object.entries(this.heldKeyCodes.value).map(([key, code]) => `${key}: ${code}`).join(' + ')
return html`
<div>
Currently pressed: ${heldCodes || 'None'}
</div>
`
}
}class KeyDisplay extends LitElement {
private heldKeyCodes = new HeldKeyCodesController(this)
render() {
const heldCodes = Object.entries(this.heldKeyCodes.value).map(([key, code]) => `${key}: ${code}`).join(' + ')
return html`
<div>
Currently pressed: ${heldCodes || 'None'}
</div>
`
}
}new HeldKeyCodesController(_host): HeldKeyCodesController;new HeldKeyCodesController(_host): HeldKeyCodesController;Defined in: controllers/held-key-codes.ts:41
ReactiveControllerHost
The Lit component that owns this controller.
HeldKeyCodesController
get value(): Record<string, string>;get value(): Record<string, string>;Defined in: controllers/held-key-codes.ts:34
Map of currently held key names to their physical event.code values.
Record<string, string>
hostConnected(): void;hostConnected(): void;Defined in: controllers/held-key-codes.ts:46
Subscribes to the tracker store and updates the internal state when changes occur.
void
ReactiveController.hostConnectedReactiveController.hostConnectedhostDisconnected(): void;hostDisconnected(): void;Defined in: controllers/held-key-codes.ts:62
Unsubscribes from the tracker store and stops tracking the held key codes.
void
ReactiveController.hostDisconnectedReactiveController.hostDisconnected