Interface: KeyboardShortcut
Defined in: packages/blockly/core/shortcut_registry.ts:379
Interface defining a keyboard shortcut.
Properties index
| Property | Description |
|---|---|
| callback | The function to be called when the shorctut is invoked. |
| name | The name of the shortcut. Should be unique. |
| preconditionFn | A function to be called when the shortcut is invoked, before calling callback, to decide if this shortcut is applicable in the current situation. |
| metadata | Optional arbitray extra data attached to the shortcut. |
| keyCodes | Optional list of key codes to be bound (via ShortcutRegistry.prototype.addKeyMapping) to this shortcut. |
| allowCollision | Value of allowCollision to pass to addKeyMapping when binding this shortcut's .keyCodes (if any). |
| displayText | Display text for the shortcut. This is not used in core but may be used by plugins or applications to provide a user-facing label for the shortcut. |
Properties
callback?
optional callback?: (workspace, e, shortcut, scope) => boolean;
Defined in: packages/blockly/core/shortcut_registry.ts:395
The function to be called when the shorctut is invoked.
Parameters
| Parameter | Type | Description |
|---|---|---|
workspace | WorkspaceSvg | The WorkspaceSvg when the shortcut was invoked. |
e | Event | The event that caused the shortcut to be activated. |
shortcut | KeyboardShortcut | The KeyboardShortcut that was activated (i.e., the one this callback is attached to). |
scope | Scope | Information about the focused item when the shortcut was invoked. |
Returns
boolean
Returning true ends processing of the invoked keycode. Returning false causes processing to continue with the next-most-recently registered shortcut for the invoked keycode.
name
name: string;
Defined in: packages/blockly/core/shortcut_registry.ts:403
The name of the shortcut. Should be unique.
preconditionFn?
optional preconditionFn?: (workspace, scope) => boolean;
Defined in: packages/blockly/core/shortcut_registry.ts:416
A function to be called when the shortcut is invoked, before
calling callback, to decide if this shortcut is applicable in
the current situation.
Parameters
| Parameter | Type | Description |
|---|---|---|
workspace | WorkspaceSvg | The WorkspaceSvg where the shortcut was invoked. |
scope | Scope | Information about the focused item when the shortcut would be invoked. |
Returns
boolean
True iff callback function should be called.
metadata?
optional metadata?: object;
Defined in: packages/blockly/core/shortcut_registry.ts:419
Optional arbitray extra data attached to the shortcut.
keyCodes?
optional keyCodes?: (string | number)[];
Defined in: packages/blockly/core/shortcut_registry.ts:425
Optional list of key codes to be bound (via ShortcutRegistry.prototype.addKeyMapping) to this shortcut.
allowCollision?
optional allowCollision?: boolean;
Defined in: packages/blockly/core/shortcut_registry.ts:436
Value of allowCollision to pass to addKeyMapping when
binding this shortcut's .keyCodes (if any).
N.B.: this is only used for binding keycodes at the time this
shortcut is initially registered, not for any subsequent
addKeyMapping calls that happen to reference this shortcut's
name.
displayText?
optional displayText?: string | (() => string);
Defined in: packages/blockly/core/shortcut_registry.ts:443
Display text for the shortcut. This is not used in core but may be used by plugins or applications to provide a user-facing label for the shortcut.