Defined in: packages/ember-hotkeys/src/onHotkey.ts:14
Attaches a shortcut to the element that owns the modifier.
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
Owner
An instance of an Owner (for service injection etc.).
ArgsFor<{ Args: { Named: ElementHotkeyOptions; Positional: [RegisterableHotkey, HotkeyCallback]; }; Element: HTMLElement; }>
The positional and named arguments passed to the modifier.
OnHotkey
Modifier<{
Element: HTMLElement
Args: {
Positional: [RegisterableHotkey, HotkeyCallback]
Named: ElementHotkeyOptions
}
}>.constructor[Invoke]: (element, ...args) => ModifierReturn;Defined in: node_modules/.pnpm/@glint+template@1.9.0/node_modules/@glint/template/-private/integration.d.ts:22
HTMLElement
...[RegisterableHotkey, HotkeyCallback, NamedArgs<ElementHotkeyOptions>]
ModifierReturn
Modifier.[Invoke]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);
}
}HTMLElement
The element to which the modifier is applied.
[RegisterableHotkey, HotkeyCallback]
The positional arguments to the modifier.
void
Modifier.modify