Founding price: $35, then $99 after 23:59 UTC on 4 November, then $99
Get ProTrue while a key (or any of several) is held down, resetting when the window loses focus so a stuck key never lingers.
This item has no props to tune. Use the lens above to change theme, density, direction and more.
Use it for modifier-driven behaviour: show copy cursors while Alt is held, multi-select while Shift or Ctrl is down, space-to-pan on a canvas or a push-to-talk key.
Do not use it for one-shot shortcuts (use useHotkey), for typing into fields, or as the only way to use a feature.
import { useKeyHeld } from "@/hooks/use-key-held"const shift = useKeyHeld("Shift")
const panning = useKeyHeld([" ", "Spacebar"])useKeyHeld(keys: string | string[], options?): boolean
| Name / option | Type | Default | Description |
|---|---|---|---|
keys | string | string[] | - | event.key values, compared ignoring case. |
enabled | boolean (option) | true | Listen only while true. |
ignoreInputs | boolean (option) | true | Ignore key presses that start in inputs, textareas and editable elements. |
The value resets to false on window blur and when the tab becomes hidden, because the keyup would be missed. Listeners are removed on unmount.
Do not make a feature available only while a key is held; it is hard for people who cannot hold keys (WCAG 2.1.1, 2.5.7). Offer a toggle or button alternative.
The hook ships with renderHook tests (use-key-held.test.ts) covering its behaviour, cleanup on unmount and server-safe defaults. It is safe to render on the server.