Docs
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Convex
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Convex
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
Format for Display API Reference
Held Keys API Reference

getHeldKeys

Function: getHeldKeys()

ts
function getHeldKeys(): SvelteHeldKeys;

Defined in: packages/svelte-hotkeys/src/getHeldKeys.svelte.ts:38

Svelte function that returns reactive access to currently held keyboard keys.

This function uses the global KeyStateTracker and updates whenever keys are pressed or released.

Returns

SvelteHeldKeys

Object with a reactive keys property

Example

svelte
<script>
  import { getHeldKeys } from '@tanstack/svelte-hotkeys'

  const heldKeys = getHeldKeys()
</script>
<div>
  Currently pressed: {heldKeys.keys.join(' + ') || 'None'}
</div>