Skip to content

Scope

Official

A scope receives keyboard events and binds callbacks to given hotkeys. Only one scope is active at a time, but scopes may define parent scopes (in the constructor) and inherit their hotkeys.

Import:

import { Scope } from 'obsidian';

Signature:

export class Scope

Constructor

new Scope(parent?: Scope | undefined)

Constructor.

To get the constructor instance, use getScopeConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
cb(() => boolean) | undefinedCallback to execute when scope is matched
keysKeyScope[]Overridden keys that exist in this scope.
parentScope | undefinedobsidian#Scope that this scope is a child of
tabFocusContainerElHTMLElement | nullContainer element that constrains tab-key focus cycling.
winnull | WindowThe window this scope is bound to, or null when not bound to a specific window.

Methods

MethodReturnsDescription
handleKey(event, keypress)unknownExecute keypress within this scope.
register(modifiers, key, func)KeymapEventHandlerAdd a keymap event handler to this scope.
setTabFocusContainer(container)voidSet the container element for constraining tab-key focus cycling.
setTabFocusContainerEl(containerEl)voidSets the container element used for tab-focus handling.
unregister(handler)voidRemove an existing keymap event handler.

Links to this page: