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

createHeldKeys

Function: createHeldKeys()

ts
function createHeldKeys(): () => string[];
function createHeldKeys(): () => string[];

Defined in: createHeldKeys.ts:26

SolidJS primitive that returns a signal of currently held keyboard keys.

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

Returns

Signal accessor for array of currently held key names

ts
(): string[];
(): string[];

Returns

string[]

Example

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

  return (
    <div>
      Currently pressed: {heldKeys().join(' + ') || 'None'}
    </div>
  )
}
function KeyDisplay() {
  const heldKeys = createHeldKeys()

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