本页还没有译文
本页 15 段还没译成简体中文,下面显示的是英文原文。createHotkeys
还没翻译译自英文(tanstack.com)本页 15 段都还没译
function createHotkeys(hotkeys, commonOptions?): void;Defined in: createHotkeys.ts:66
SolidJS primitive for registering multiple keyboard hotkeys at once.
Uses the singleton HotkeyManager for efficient event handling. Accepts a dynamic array of hotkey definitions, making it safe to use with variable-length lists.
Options are merged in this order: HotkeysProvider defaults < commonOptions < per-definition options
Parameters
hotkeys
| CreateHotkeyDefinition[]
| (() => CreateHotkeyDefinition[])
Array of hotkey definitions, or accessor returning them
commonOptions?
| CreateHotkeyOptions
| (() => CreateHotkeyOptions)
Shared options applied to all hotkeys, or accessor
Returns
void
Examples
function Editor() {
createHotkeys([
{ hotkey: 'Mod+S', callback: () => save() },
{ hotkey: 'Mod+Z', callback: () => undo() },
{ hotkey: 'Escape', callback: () => close() },
])
}function MenuShortcuts(props) {
createHotkeys(
() => props.items.map((item) => ({
hotkey: item.shortcut,
callback: item.action,
options: { enabled: item.enabled },
})),
{ preventDefault: true },
)
}AI 翻译查看英文原文