Skip to content

Scope.register method

Scope › register

Official

Add a keymap event handler to this scope.

Signature:

register(modifiers: Modifier[] | null, key: string | null, func: KeymapEventListener): KeymapEventHandler

Parameters:

ParameterTypeDescription
modifiersModifier[] | nullMod, 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.
keystring | nullKey value from {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values}, or null to capture all keys.
funcKeymapEventListenerthe 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');
});