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
App Hotkeys API Reference
Key hold & held keys API Reference
Hotkey Recorder API Reference
Normalization & format API Reference
Hotkeys API Reference

createHotkeys

ts
function createHotkeys(hotkeys, commonOptions?): void;
function createHotkeys(hotkeys, commonOptions?): void;

Defined in: packages/svelte-hotkeys/src/createHotkeys.svelte.ts:128

Svelte function for registering several hotkeys at once on the document: chords, sequences, and app hotkeys. Pass getters for reactive values. Use createHotkeysAttachment for element-scoped hotkeys.

Options merge in this order: provider defaults, app hotkey declaration, commonOptions, per-hotkey options. Each option applies only to the kinds that support it. Unbound app hotkeys and empty sequences register nothing.

Parameters

hotkeys

MaybeGetter<readonly CreateHotkeyDefinition[]>

commonOptions?

MaybeGetter<CreateHotkeyCommonOptions> = {}

Returns

void

Example

svelte
<script lang="ts">
  createHotkeys([
    { hotkey: 'Mod+S', callback: () => save() },
    { hotkey: ['G', 'G'], callback: () => scrollToTop(), options: { timeout: 500 } },
  ])
</script>
<script lang="ts">
  createHotkeys([
    { hotkey: 'Mod+S', callback: () => save() },
    { hotkey: ['G', 'G'], callback: () => scrollToTop(), options: { timeout: 500 } },
  ])
</script>