Docs
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
Hotkeys API Reference
Hotkey Sequence API Reference
Key hold & held keys API Reference
Hotkey Recorder API Reference
Hotkey Sequence Recorder API Reference
Normalization & format API Reference
Key hold & held keys API Reference

useHeldKeys

Function: useHeldKeys()

ts
function useHeldKeys(): string[];

Defined in: useHeldKeys.ts:26

Preact hook that returns an array of currently held keyboard keys.

This hook uses useStore from @tanstack/preact-store to subscribe to the global KeyStateTracker and updates whenever keys are pressed or released.

Returns

string[]

Array of currently held key names

Example

tsx
function KeyDisplay() {
  const heldKeys = useHeldKeys()

  return (
    <div>
      Currently pressed: {heldKeys.join(' + ') || 'None'}
    </div>
  )
}