Shortcuts

The shortcut keys in the editor are managed uniformly by the Shortcut Key Manager. Each shortcut key needs to be bound to a message. When the shortcut key is pressed, the bound message is triggered.

Define

  1. {
  2. "name": "hello-world",
  3. "panels": {
  4. "default": {
  5. "main": "./panel.js"
  6. }
  7. },
  8. "contributions": {
  9. "messages": {
  10. "undo": {
  11. "title": "i18n:hello.messages.undo.title",
  12. "methods": ["say-undo"]
  13. }
  14. },
  15. "shortcuts": [
  16. {
  17. "message": "undo",
  18. "when": "panel.hello-world",
  19. "win": "ctrl+z",
  20. "mac": "cmd+z",
  21. }
  22. ]
  23. }
  24. }

For details, please refer to the Message documentation.

contributions.shortcuts Parameter Description:

message

Type {string} Required

The message bound to the shortcut key is sent when the shortcut key is triggered.

when(experimental)

Type {string} Optional

Note: this is an experimental feature, this functional syntax may be adjusted in the future.

This shortcut will only be triggered under certain conditions.

panel.hello-world will only take effect when the hello-world panel gets the focus.

win

Type {string} Required

On the windows platform, the monitored button.

mac

Type {string} Required

On MacOS, monitor keystrokes.