ShortcutManager

The ShortcutManager API allows developers to register keyboard shortcuts for specified actions using JS or TS.

Version compatibility

  • ShortcutManager was introduced in version 4.58.0 of the JourneyApps Runtime.

  • Keyboard shortcuts are only supported on Desktop.

This document describes registering and unregistering keyboard shortcuts via JS/TS. For the shortcut XML components see these docs.

Basic Example

main.js
ShortcutManager.registerShortcut('CTRL+SHIFT+K', function() {
    notification.info('CTRL+SHIFT+K was pressed');
});

Methods

registerShortcut

ShortcutManager.registerShortcut(keys, callback)

Allows developers to register a new keyboard shortcut, and specify the corresponding action (via a callback function). The key combination (keys parameter) for a shortcut is the shortcut's unique identifier, hence if duplicate shortcuts are registered, only the last registered callback action will execute.

Parameter
Type
Example

keys

string

"CTRL+K"

callback

Function

See the basic example above.

Registering shortcuts over multiple views

To have a keyboard shortcut be available globally (i.e. in multiple views of your app), the shortcut should get registered in your app's SharedJS (in a JavaScript app) or App Modules (in a TypeScript app).

Reserved keys

The following keys are reserved and hence cannot be used as keys:

  • CTRL+Z

  • CTRL+SHIFT+Z

  • CTRL+Y

  • CTRL+C

  • CTRL+V

  • CTRL+R

  • ESC

  • ENTER

  • BACKSPACE

  • DELETE

unregisterShortcut

ShortcutManager.unregisterShortcut(keys)

Allows developers to unregister a previously registered keyboard shortcut.

Parameter
Type
Example

keys

string

"CTRL+K"

Last updated