TanStack
Hotkeys API Reference

HotkeysProvider

ts
const HotkeysProvider: DefineComponent<typeof providerProps, () => VNode[] | undefined, {
}, {
}, {
}, ComponentOptionsMixin, ComponentOptionsMixin, typeof providerEmits> = component;

Defined in: HotkeysProvider.tsx:98

Vue component that provides default options, app hotkeys, and the user's custom hotkeys. A new customHotkeys value replaces the current custom hotkeys, undefined leaves them unchanged, and null clears them. Listen to custom-hotkeys-change to save changes.

Nest providers to create hotkey scopes. A nested provider inherits app hotkeys and merges default options. With scope, its hotkeys fire only while it is mounted, enabled, and not hidden by <KeepAlive>; with exclusive, only its hotkeys fire.

Props: defaultOptions (a HotkeysProviderOptions), appHotkeys, customHotkeys, and the scope, exclusive, and enabled props of HotkeysProviderScopeProps. Event: custom-hotkeys-change.

Examples

vue
<template>
  <HotkeysProvider
    :app-hotkeys="appHotkeys"
    :custom-hotkeys="saved"
    @custom-hotkeys-change="save"
  >
    <App />
  </HotkeysProvider>
</template>
vue
<HotkeysProvider scope="edit-dialog" :exclusive="{ allow: ['global'] }">
  <DialogBody />
</HotkeysProvider>