Hotkeys Docs
Getting Started
AI/LLM: This documentation page is available in plain markdown format at/hotkeys/latest/docs/framework/solid/reference/functions/createKeyLockState.md
createKeyLockState
ts
function createKeyLockState(key): () => boolean | null;Defined in: createKeyLockState.ts:35
SolidJS primitive that returns 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. It returns 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 an accessor function
Returns#
Signal accessor that returns true when the lock is on, false when it is off, or null
() => boolean | null
Example#
tsx
function PasswordField() {
const capsLock = createKeyLockState('CapsLock')
return (
<label>
Password
<input type="password" />
<Show when={capsLock()}>
<span role="status">Caps Lock is on</span>
</Show>
</label>
)
}