本页还没有译文
本页 17 段还没译成简体中文,下面显示的是英文原文。createHotkeyHandler
还没翻译译自英文(tanstack.com)本页 17 段都还没译
function createHotkeyHandler(
hotkey,
callback,
options?): (event) => void;Defined in: match.ts:87
Creates a keyboard event handler that calls the callback when the hotkey matches.
Parameters
hotkey
| Hotkey
| ParsedHotkey
The hotkey string or ParsedHotkey to match
callback
The function to call when the hotkey matches
options?
CreateHotkeyHandlerOptions = {}
Options for matching and handling
Returns
A function that can be used as an event handler
(event) => void
Example
const handler = createHotkeyHandler('Mod+S', (event, { hotkey, parsedHotkey }) => {
console.log(`${hotkey} was pressed`)
handleSave()
})
document.addEventListener('keydown', handler)AI 翻译查看英文原文