Scope.register method
Scope › register
Official
Add a keymap event handler to this scope.Signature:
register(modifiers: Modifier[] | null, key: string | null, func: KeymapEventListener): KeymapEventHandlerParameters:
| Parameter | Type | Description |
|---|---|---|
| modifiers | Modifier[] | null | Mod, Ctrl, Meta, Shift, or Alt. Mod translates to Meta on macOS and Ctrl otherwise. Pass null to capture all events matching the key, regardless of modifiers. |
| key | string | null | Key value from {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values}, or null to capture all keys. |
| func | KeymapEventListener | the callback that will be called when a user triggers the keybind. |
Returns: KeymapEventHandler — The keymap event handler, which can be passed to Scope.unregister.
Example:
scope.register(['Mod', 'Shift'], 'L', (evt, ctx) => { console.log('Mod+Shift+L pressed');});