本页还没有译文
本页 46 段还没译成Español,下面显示的是英文原文。onHotkey
还没翻译译自英文(tanstack.com)本页 46 段都还没译
Defined in: packages/ember-hotkeys/src/onHotkey.ts:14
Attaches a shortcut to the element that owns the modifier.
Extends
default<{Args: {Named:ElementHotkeyOptions;Positional: [RegisterableHotkey,HotkeyCallback]; };Element:HTMLElement; }>
Constructors
Constructor
new onHotkey(owner, args): OnHotkey;Defined in: node_modules/.pnpm/ember-modifier@4.2.2_@babel+core@7.29.7_supports-color@8.1.1__supports-color@8.1.1/node_modules/ember-modifier/declarations/-private/class-based/modifier.d.ts:26
Parameters
owner
Owner
An instance of an Owner (for service injection etc.).
args
ArgsFor<{
Args: {
Named: ElementHotkeyOptions;
Positional: [RegisterableHotkey, HotkeyCallback];
};
Element: HTMLElement;
}>
The positional and named arguments passed to the modifier.
Returns
OnHotkey
Inherited from
Modifier<{
Element: HTMLElement
Args: {
Positional: [RegisterableHotkey, HotkeyCallback]
Named: ElementHotkeyOptions
}
}>.constructorProperties
[Invoke]
[Invoke]: (element, ...args) => ModifierReturn;Defined in: node_modules/.pnpm/@glint+template@1.9.0/node_modules/@glint/template/-private/integration.d.ts:22
Parameters
element
HTMLElement
args
...[RegisterableHotkey, HotkeyCallback, NamedArgs<ElementHotkeyOptions>]
Returns
ModifierReturn
Inherited from
Modifier.[Invoke]Methods
modify()
modify(
element,
positional,
options): void;Defined in: packages/ember-hotkeys/src/onHotkey.ts:25
Called when the modifier is installed and any time any tracked state used in the modifier changes.
If you need to do first-time-only setup, create a class field representing
the initialization state and check it when running the hook. That is also
where and when you should use registerDestructor for any teardown you
need to do. For example:
function disconnect(instance) {
instance.observer?.disconnect();
}
class IntersectionObserver extends Modifier {
observer;
constructor(owner, args) {
super(owner, args);
registerDestructor(this, disconnect);
}
modify(element, callback, options) {
disconnect(this);
this.observer = new IntersectionObserver(callback, options);
this.observer.observe(element);
}
}Parameters
element
HTMLElement
The element to which the modifier is applied.
positional
[RegisterableHotkey, HotkeyCallback]
The positional arguments to the modifier.
options
Returns
void
Overrides
Modifier.modify