Tutorial: globalhotkey.addEventListener

globalhotkey.addEventListener

Registers an event listener on the specified event. Supported global hotkey event types are:

  • registered
  • unregistered

Example

fin.desktop.System.addEventListener('registered', function (evnt) {
    console.log(` window ${evnt.identity.name} has registered ${evnt.hotkey}`, evnt);
}, function () {
    console.log("The registration was successful");
},function (r, err) {
    console.log("failure: " + err);
});

GlobalHotkey Events

registered

Generated when a hotkey has been registered with the operating system

//This response has the following shape:
{
  "topic": "global-hotkey",
  "type": "registered",
  "identity": { //The Identity that has just registered the hotkey
    "name": "testapp",
    "uuid": "454C7F31-A915-4EA2-83F2-CFA655453C52",
    "parentFrame": "testapp",
    "entityType": "window"
  },
  "hotkey": "CommandOrControl+X"
}

unregistered

Generated when a hotkey has been unregistered with the operating system

//This response has the following shape:
{
  "topic": "global-hotkey",
  "type": "unregistered",
  "identity": {
    "name": "testapp",
    "uuid": "454C7F31-A915-4EA2-83F2-CFA655453C52",
    "parentFrame": "testapp",
    "entityType": "window"
  },
  "hotkey": "CommandOrControl+X"
}