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

provideHotkeysContext

ts
function provideHotkeysContext(options?): void;
function provideHotkeysContext(options?): void;

Defined in: HotkeysProviderContext.ts:98

Provides default options, app hotkeys, and the user's custom hotkeys to descendants. HotkeysProvider calls this; call it directly in a component's setup instead of rendering the provider.

Nest contexts to create hotkey scopes. A nested context inherits app hotkeys and merges default options. With scope, its hotkeys fire only while the component is mounted and enabled; with exclusive, only its hotkeys fire.

Parameters

options?

ProvideHotkeysContextOptions = {}

Returns

void

Example

ts
provideHotkeysContext({
  appHotkeys,
  customHotkeys: JSON.parse(localStorage.getItem('hotkeys') ?? '{}'),
  onCustomHotkeysChange: (custom) =>
    localStorage.setItem('hotkeys', JSON.stringify(custom)),
})
provideHotkeysContext({
  appHotkeys,
  customHotkeys: JSON.parse(localStorage.getItem('hotkeys') ?? '{}'),
  onCustomHotkeysChange: (custom) =>
    localStorage.setItem('hotkeys', JSON.stringify(custom)),
})