shortcuts([shortcuts])
Class: Button. Method inherited from UIComponent.
Description:
Sets or gets an array of keyboard shortcuts handled by onShortcut() event handler.
Parameters:
| Name | Type | Description |
|---|---|---|
|
|
Array.<object> | Array.<string> |
An array of shortcut objects {shortcut:{string}, scope: {ShortcutScope}}, or an Array of String shortcuts (for strings a default ShortcutScope will be assigned). |
Returns:
If called without arguments, then current shortcuts array is returned, otherwise an instance of this component is returned.
Type: this | Array.<object>
Examples:
Setting shortcuts as strings
window.shortcuts(["f1", "ctrl+s"]);
Setting shortcuts as objects
window.shortcuts([
{
key: "control+s",
scope: ShortcutScope.Window, // optional
action: "save_file" // optional
}
]);
Clearing all shortcuts
window.shortcuts([]); // pass an empty array
Retrieving current shortcuts
const shortcuts = window.shortcuts(); // returns an Array of objects with `key` and `scope` properties.
