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
Hotkeys API Reference

createHotkey

Function: createHotkey()

ts
function createHotkey(
   hotkey, 
   callback, 
   options): void;

Defined in: packages/svelte-hotkeys/src/createHotkey.svelte.ts:70

Register a global hotkey for the current component.

Parameters

hotkey

MaybeGetter<RegisterableHotkey>

callback

HotkeyCallback

options

MaybeGetter<CreateHotkeyOptions> = {}

Returns

void

Example

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

  createHotkey('Mod+S', () => {
    console.log('Mod+S pressed')
  })
</script>