function useKeyLockState(key): ComputedRef<boolean | null>;Defined in: useKeyLockState.ts:39
Vue composable that returns a reactive ref telling 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 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. The key may be a ref or getter; the result follows it without waiting for an event. Pressing or releasing a key that doesn't change the lock state doesn't notify anything that reads the ref.
MaybeRefOrGetter<LockKey>
'CapsLock', 'NumLock', or 'ScrollLock'
ComputedRef<boolean | null>
Read-only reactive ref that is true when the lock is on, false when it is off, or null
<script setup>
import { useKeyLockState } from '@tanstack/vue-hotkeys'
const capsLock = useKeyLockState('CapsLock')
</script>
<template>
<label>
Password
<input type="password" />
<span v-if="capsLock" role="status">Caps Lock is on</span>
</label>
</template>