本页还没有译文
本页 13 段还没译成Deutsch,下面显示的是英文原文。createHotkeyRecorder
还没翻译译自英文(tanstack.com)本页 13 段都还没译
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 useSelector from @tanstack/solid-store to subscribe
to the recorder's store state (same pattern as useHotkeyRecorder in React).
Parameters
options
HotkeyRecorderOptions | (() => HotkeyRecorderOptions)
Configuration options for the recorder (or accessor function)
Returns
An object with recording state signals and control functions
Example
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>
)
}AI 翻译查看英文原文