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
API Reference
Hotkeys API Reference
Hotkey Sequence API Reference
Key Hold API Reference
Held Keys API Reference
Hotkey Recorder API Reference
Hotkey Sequence Recorder API Reference
Format for Display API Reference
Held Keys API Reference

useHeldKeys

Function: useHeldKeys()

ts
function useHeldKeys(): string[];

Defined in: useHeldKeys.ts:26

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

This hook uses useStore from @tanstack/react-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>
  )
}