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
KeyboardShortcutsAPIMethods#
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#
| Parameter | Type | Description |
|---|---|---|
shortcut | KeyboardShortcut |
Returns#
A disposer that removes everything this call registered.
() => void
Signature#
set(shortcut: KeyboardShortcut | KeyboardShortcut[]): () => voidlist()#
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.
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#
| Parameter | Type |
|---|---|
options | { scopes: any; } |
options.scopes | any |
Returns#
Signature#
list(options: object): KeyboardShortcut[]get()#
Get the first keyboard shortcut matching options, or undefined. See
list for the matching rules.
options, or undefined. See
list for the matching rules.Parameters#
| Parameter | Type |
|---|---|
options | { keys: string |
options.keys | string |
options.scopes | any |
Returns#
KeyboardShortcutSignature#
get(options: object): KeyboardShortcutremove()#
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.
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#
| Parameter | Type |
|---|---|
options | { keys: string |
options.keys | string |
options.scopes | any |
Returns#
void
Signature#
remove(options: object): voidhas()#
Whether a key combination or sequence is in use.
Parameters#
| Parameter | Type | Description |
|---|---|---|
keys | string |
Returns#
boolean
Signature#
has(keys: string | KeyboardKey[]): booleansetEnabled()#
Enable or disable the whole keyboard layer. Disabling detaches the listener
without unregistering shortcuts, so re-enabling restores them.
Parameters#
| Parameter | Type | Description |
|---|---|---|
enabled | boolean | true to enable, false to disable. |
Returns#
void
Signature#
setEnabled(enabled: boolean): voidaddScope()#
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.
data-shortcut-scope.Parameters#
| Parameter | Type | Description |
|---|---|---|
id | any | The scope id to recognise. |
Returns#
A disposer that unregisters the scope id.
() => void
Signature#
addScope(id: any): () => voidsetRoot()#
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#
| Parameter | Type | Description |
|---|---|---|
target | ShortcutRoot | The element/document to bind to. |
Returns#
A disposer that stops listening.
() => void
Signature#
setRoot(target: ShortcutRoot): () => void