Search Docs
Loading...
Skip to content

Class: KeyboardShortcutsAPI

cesdk.shortcuts — the editor-facing keyboard shortcut API.

A thin wrapper over the engine’s engine.shortcuts registry that translates the editor-facing KeyboardShortcut (whose when/run receive a context with cesdk) to/from the engine Shortcut (whose callbacks receive a context with engine). The cesdk instance is closed over here so the engine layer never needs to know about it.

Constructors#

Constructor#


KeyboardShortcutsAPI

Methods#

set()#


Register one keyboard shortcut, or many at once.

A shortcut’s identity is its keys + scope: registering the same combination again replaces it. Pass an array to register several in one call.

Parameters#

ParameterTypeDescription
shortcutKeyboardShortcut

Returns#

A disposer that removes everything this call registered.

() => void

Signature#

set(shortcut: KeyboardShortcut | KeyboardShortcut[]): () => void

list()#


List the keyboard shortcuts whose scope matches options.scopes (glob-matched). scopes is required and must be non-empty; { scopes: ’*’ } lists everything. Throws on an empty scopes. To find a shortcut by chord use get/has.

Parameters#

ParameterType
options{ scopes: any; }
options.scopesany

Returns#

KeyboardShortcut[]

Signature#

list(options: object): KeyboardShortcut[]

get()#


Get the first keyboard shortcut matching options, or undefined. See list for the matching rules.

Parameters#

ParameterType
options{ keys: string
options.keysstring
options.scopesany

Returns#

KeyboardShortcut

Signature#

get(options: object): KeyboardShortcut

remove()#


Remove every keyboard shortcut matching options (keys AND scopes). Both fields are required and must be non-empty; use ’*’ to match all — for example, keys: ‘Mod+s’ with scopes: ’*’ removes that chord from every scope. Throws on an empty field.

Parameters#

ParameterType
options{ keys: string
options.keysstring
options.scopesany

Returns#

void

Signature#

remove(options: object): void

has()#


Whether a key combination or sequence is in use.

Parameters#

ParameterTypeDescription
keysstring

Returns#

boolean

Signature#

has(keys: string | KeyboardKey[]): boolean

clear()#


Remove every registered keyboard shortcut.

Returns#

void

Signature#

clear(): void

setEnabled()#


Enable or disable the whole keyboard layer. Disabling detaches the listener without unregistering shortcuts, so re-enabling restores them.

Parameters#

ParameterTypeDescription
enabledbooleantrue to enable, false to disable.

Returns#

void

Signature#

setEnabled(enabled: boolean): void

addScope()#


Register a UI scope id the dispatcher should recognise while resolving the active scope. The editor wires its built-in scopes automatically; use this for custom surfaces stamped with data-shortcut-scope.

Parameters#

ParameterTypeDescription
idanyThe scope id to recognise.

Returns#

A disposer that unregisters the scope id.

() => void

Signature#

addScope(id: any): () => void

setRoot()#


Set the DOM root the keyboard layer binds to (the capture-phase keydown listener and scope resolution). The editor sets this to its container automatically; override only for custom mounting.

Parameters#

ParameterTypeDescription
targetShortcutRootThe element/document to bind to.

Returns#

A disposer that stops listening.

() => void

Signature#

setRoot(target: ShortcutRoot): () => void