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

createHotkeyRecorder

Function: createHotkeyRecorder()

ts
function createHotkeyRecorder(options): SolidHotkeyRecorder;
function createHotkeyRecorder(options): SolidHotkeyRecorder;

Defined in: createHotkeyRecorder.ts:61

SolidJS primitive for recording keyboard shortcuts.

This primitive provides a thin wrapper around the framework-agnostic HotkeyRecorder class, managing all the complexity of capturing keyboard events, converting them to hotkey strings, and handling edge cases like Escape to cancel or Backspace/Delete to clear.

This primitive uses useStore from @tanstack/solid-store to subscribe to the recorder's store state (same pattern as useHotkeyRecorder in React).

Parameters

options

Configuration options for the recorder (or accessor function)

HotkeyRecorderOptions | () => HotkeyRecorderOptions

Returns

SolidHotkeyRecorder

An object with recording state signals and control functions

Example

tsx
function ShortcutSettings() {
  const [shortcut, setShortcut] = createSignal<Hotkey>('Mod+S')

  const recorder = createHotkeyRecorder({
    onRecord: (hotkey) => {
      setShortcut(hotkey)
    },
    onCancel: () => {
      console.log('Recording cancelled')
    },
  })

  return (
    <div>
      <button onClick={recorder.startRecording}>
        {recorder.isRecording() ? 'Recording...' : 'Edit Shortcut'}
      </button>
      <Show when={recorder.recordedHotkey()}>
        <div>Recording: {recorder.recordedHotkey()}</div>
      </Show>
    </div>
  )
}
function ShortcutSettings() {
  const [shortcut, setShortcut] = createSignal<Hotkey>('Mod+S')

  const recorder = createHotkeyRecorder({
    onRecord: (hotkey) => {
      setShortcut(hotkey)
    },
    onCancel: () => {
      console.log('Recording cancelled')
    },
  })

  return (
    <div>
      <button onClick={recorder.startRecording}>
        {recorder.isRecording() ? 'Recording...' : 'Edit Shortcut'}
      </button>
      <Show when={recorder.recordedHotkey()}>
        <div>Recording: {recorder.recordedHotkey()}</div>
      </Show>
    </div>
  )
}