javascriptnode.jselectron

NodeJS/Electron: Is it possible to register "STRG+<" as a globalShortcut and how can I do this?


I'm trying to register STRG+< as a globalShortcut in my electron app. It was possible to register this hotkey with autoit, so I don't think nodejs/electron can't.

Can you please help me?

The following hotkey is working: CommandOrControl+X

This is not working: CommandOrControl+<

In the internet I didn't find the corresponding keycode for Javascript.

const globalHotkey = globalShortcut.register('CommandOrControl+X', () => {
    console.log('CommandOrControl+X is pressed')
})
if (!globalHotkey) {
    console.log('registration failed')
}

Solution

  • Someone helped me and suggested ioHook.

    https://discuss.atom.io/t/register-strg-as-a-globalshortcut-in-electron/66963/2

    const ioHook = require('iohook')
    // register "STRG+<"   
    const id = ioHook.registerShortcut([29, 0], (keys) => {
        console.log('-----------------------------')
        console.log('Shortcut was pressed:', keys)
    })