Docs
CodeRabbit
Cloudflare
Railway
Clerk
OpenRouter
AG Grid
WorkOS
Netlify
SerpAPI
Unkey
Electric
Sentry
Prisma
CodeRabbit
Cloudflare
Railway
Clerk
OpenRouter
AG Grid
WorkOS
Netlify
SerpAPI
Unkey
Electric
Sentry
Prisma
API Reference
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
Hotkeys API Reference

createHotkeys

Function: createHotkeys()

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

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

Register multiple global hotkeys for the current component.

Parameters

hotkeys

MaybeGetter<CreateHotkeyDefinition[]>

commonOptions

MaybeGetter<CreateHotkeyOptions> = {}

Returns

void

Example

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

  createHotkeys([
    { hotkey: 'Mod+S', callback: () => save() },
    { hotkey: 'Mod+Z', callback: () => undo() },
    { hotkey: 'Escape', callback: () => close() },
  ])
</script>
<script lang="ts">
  import { createHotkeys } from '@tanstack/svelte-hotkeys'

  createHotkeys([
    { hotkey: 'Mod+S', callback: () => save() },
    { hotkey: 'Mod+Z', callback: () => undo() },
    { hotkey: 'Escape', callback: () => close() },
  ])
</script>