本页还没有译文
本页 16 段还没译成Deutsch,下面显示的是英文原文。injectHotkeys
还没翻译译自英文(tanstack.com)本页 16 段都还没译
function injectHotkeys(hotkeys, commonOptions?): void;Defined in: injectHotkeys.ts:75
Angular inject-based API for registering multiple keyboard hotkeys at once.
Uses the singleton HotkeyManager for efficient event handling. Accepts a dynamic array of hotkey definitions.
Call in an injection context (e.g. constructor or field initializer). Uses effect() to track reactive dependencies and update registrations when options or the callback change.
Options are merged in this order: provideHotkeys defaults < commonOptions < per-definition options
Parameters
hotkeys
| InjectHotkeyDefinition[]
| (() => InjectHotkeyDefinition[])
Array of hotkey definitions, or getter returning them
commonOptions?
| InjectHotkeyOptions
| (() => InjectHotkeyOptions)
Shared options for all hotkeys, or getter
Returns
void
Examples
@Component({ ... })
export class EditorComponent {
constructor() {
injectHotkeys([
{ hotkey: 'Mod+S', callback: () => this.save() },
{ hotkey: 'Mod+Z', callback: () => this.undo() },
{ hotkey: 'Escape', callback: () => this.close() },
])
}
}@Component({ ... })
export class DynamicShortcuts {
shortcuts = signal([...])
constructor() {
injectHotkeys(
() => this.shortcuts().map((s) => ({
hotkey: s.key,
callback: s.action,
})),
)
}
}AI 翻译查看英文原文