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
Hotkey Sequence API Reference

createHotkeySequenceAttachment

Function: createHotkeySequenceAttachment()

ts
function createHotkeySequenceAttachment(
   sequence, 
   callback, 
options): Attachment<HTMLElement>;

Defined in: packages/svelte-hotkeys/src/createHotkeySequence.svelte.ts:113

Create an attachment for element-scoped keyboard sequences.

Parameters

sequence

MaybeGetter<HotkeySequence>

callback

HotkeyCallback

options

MaybeGetter<CreateHotkeySequenceOptions> = {}

Returns

Attachment<HTMLElement>

Example

svelte
<script lang="ts">
  import { createHotkeySequenceAttachment } from '@tanstack/svelte-hotkeys'

  const vimKeys = createHotkeySequenceAttachment(['G', 'G'], () => {
    scrollToTop()
  })
</script>

<div tabindex="0" {@attach vimKeys}>
  Focus here and press g then g
</div>