Hotkeys

Overview

The Hotkeys API allows applications to register key combinations and receive notifications when a key combination is pressed by the user irrespective of whether the application is on focus or not.
Hotkeys is useful for web applications that do not have access to system resources and cannot register global shortcuts.

The Hotkeys API can be accessed through glue.hotkeys.

Configuration

You can control the hotkeys behavior from the system.json file under the hotkeys top-level key. You can find the system.json in the %LocalAppData%\Tick42\GlueDesktop\config folder. See the Configuration section for more details on configuring your apps. The system.json has the following properties:

  • enabled - if true, hotkeys will be enabled;
  • whitelist - list of applications that can register hotkeys; any app not on the list cannot register hotkeys;
  • blacklist - list of applications that cannot register hotkeys; any app not on the list can register hotkeys;
  • reservedHotkeys - list of reserved (system or other) hotkeys that cannot be overriden by other applications;

Hotkeys configuration example:

{
    "hotkeys": {
        "enabled": true,
        "blacklist": ["appManager"],
        "reservedHotkeys": ["ctrl+c", "ctrl+p", "ctrl+s"]
    }
}

Hotkeys API

The Hotkeys API is exposed through the glue.hotkeys object. To register a hotkey, your application must be using a glue.js version newer than 4.3.5.

Registering a hotkey:

// define a hotkey object
const hotkeyClientDetails = {
    hotkey: "shift+alt+c",
    description: "Open Client Details"
};

// register the hotkey
glue.hotkeys.register(hotkeyClientDetails, (details) => {
    // this function will be invoked when the hotkey is pressed
    glue.appManager.application("Client Details").start()
});

To remove a hotkey, use the glue.hotkeys.unregister() and pass the value of the hotkey property as an argument:

glue.hotkeys.unregister("shift+alt+c");

To remove all hotkeys, registered by your app, use the unregisterAll() method:

glue.hotkeys.unregisterAll();

To check if your app has registered a hotkey:

// returns true if this application has registered the specified hotkey
isRegistered(hotkey: string): void;

Hotkeys View

There is a utility view that allows you to see all hotkeys registered by different applications. You can open it from the Glue42 Desktop tray icon menu - right-click on the tray icon to display the menu:

Hotkeys Tray Icon Menu

When you click on the Hotkeys item you will see a list of the hotkeys registered by your app:

Registered Hotkeys

Reference