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).
Configuration options for the recorder (or accessor function)
HotkeyRecorderOptions | () => HotkeyRecorderOptions
An object with recording state signals and control functions
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>
)
}