useKeyLockState
function useKeyLockState(owner, key): EmberHotkeyState<boolean | null>;Defined in: packages/ember-hotkeys/src/useKeyLockState.ts:39
Returns whether a lock key, such as Caps Lock, is on. Pass the containing component as owner to release the subscription on destruction. Getter arguments can read changing tracked component properties.
Lock keys toggle instead of being held, so this reads the lock state that the browser reports on key and mouse events. Its value 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#
owner#
object
The component that owns the subscription
key#
MaybeGetter<LockKey>
'CapsLock', 'NumLock', or 'ScrollLock'
Returns#
EmberHotkeyState<boolean | null>
A state whose value is true when the lock is on, false when it is off, or null
Example#
class PasswordField extends Component {
capsLock = useKeyLockState(this, 'CapsLock')
<template>
<label>
Password
<input type="password" />
{{#if this.capsLock.value}}
<span role="status">Caps Lock is on</span>
{{/if}}
</label>
</template>
}