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(): Ref<string[]>;

Defined in: packages/vue-hotkeys/src/useHeldKeys.ts:29

Vue composable that returns a reactive ref of currently held keyboard keys.

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

Returns

Ref<string[]>

Reactive ref containing array of currently held key names

Example

vue
<script setup>
import { useHeldKeys } from '@tanstack/vue-hotkeys'

const heldKeys = useHeldKeys()
</script>

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