4.16FXB.MessageTypes.SHORTCUT_KEY

(Note: requires version 2 of the Framework)

A script can react to Ctrl+Alt keyboard shortcuts in two ways:

You assign a shortcut key to the script. The platform runs the script when you press the shortcut.

Or, a script is set to run permanently, and listens for shortcut keypresses while it is running.

(The platform only handles Ctrl+Alt+X, not Ctrl+X or Alt+X, because Ctrl+X and Alt+X are widely used by web browsers for their own shortcuts which cannot be overridden or replaced. For example, Ctrl+S and Ctrl+B are reserved shortcuts in all web browsers.)

The SHORTCUT_KEY message is fired when the user presses a Ctrl+Alt keyboard combination. The message has the following properties:

Property

Description

key

The Javascript key code of the browser keyboard event

shiftKey

The true/false state of the Shift key

For example:

Framework.OnMessage = function(Msg) {

if (Msg.is(FXB.MessageTypes.SHORTCUT_KEY)) {

if (Msg.key == "p") {

// User has pressed Ctrl+Alt+P

}

}

};

Note: for a Ctrl+Alt+Shift+X keyboard combination, two SHORTCUT_KEY notifications will be fired:

One when the Shift key is pressed, with the key value set to "Shift"

A further notification, with shiftKey = true, when the subsequent letter/number key is pressed