Hotkeys Docs
Getting Started
AI/LLM: This documentation page is available in plain markdown format at/hotkeys/latest/docs/framework/angular/reference/functions/injectKeyLockState.md
injectKeyLockState
ts
function injectKeyLockState(key): Signal<boolean | null>;Defined in: injectKeyLockState.ts:39
Angular inject-based API that returns a signal of whether a lock key, such as Caps Lock, is on.
Lock keys toggle instead of being held, so this reads the lock state that the browser reports on key and mouse events. The signal is null until the user presses a key, clicks, or moves the mouse, after the window loses focus or the page is hidden, and always for Num Lock and Scroll Lock on macOS and iOS.
Parameters#
key#
MaybeGetter<LockKey>
'CapsLock', 'NumLock', or 'ScrollLock' - can be a getter function
Returns#
Signal<boolean | null>
Signal that is true when the lock is on, false when it is off, or null
Example#
ts
@Component({
template: `
<label>
Password
<input type="password" />
@if (capsLock()) {
<span role="status">Caps Lock is on</span>
}
</label>
`,
})
export class PasswordFieldComponent {
capsLock = injectKeyLockState('CapsLock')
}