Helper for registering global shortcut
$ npm install --save electron-shortcut
const Shortcut = require('electron-shortcut');
// create and register a shortcut with auto-register when windows got focus
var shortcut = new Shortcut('Command+1', handler);
// create and register shortcuts with manual-register
var shortcut = new Shortcut(['Command+2', 'Command+3'], {
autoRegister: false
}, handler);
shortcut.register();
// with static method
Shortcut.register('Command+1', {autoRegister: true}, handler);
Shortcut.unregister();
Type: string
or 'array'
Names for shortcut to register as global shortcut
autoRegister
: default: true, Auto un/register shortcuts on windows got focus.cmdOrCtrl
: default: false, All events of Command or Cmd will be changed into Control or Ctrl by OS running your application on
Global event handler for events
Register shortcuts with shortcut list already added.
Unregister shortcuts with shortcut list already added.
Add a new shortcut
Remove a shortcut. If events is not set, remove all of events.
Return array of shortcut by event names
Update shortcut with new options by event name
Register events with static method. See Shortcut for more information of arguments.
Unregister events with static method
MIT © ragingwind