Define keyboard shortcuts.
Accelerators are Strings that can contain multiple modifiers and key codes, combined by the + character, and are used to define keyboard shortcuts throughout your application.
Examples:
CommandOrControl+ACommandOrControl+Shift+ZShortcuts are registered with the globalShortcut module using the register method, i.e.
const {app, globalShortcut} = require('electron')
app.on('ready', () => {
// Register a 'CommandOrControl+Y' shortcut listener.
globalShortcut.register('CommandOrControl+Y', () => {
// Do stuff when Y and either Command/Control is pressed.
})
})
On Linux and Windows, the Command key does not have any effect so use CommandOrControl which represents Command on macOS and Control on Linux and Windows to define some accelerators.
Use Alt instead of Option. The Option key only exists on macOS, whereas the Alt key is available on all platforms.
The Super key is mapped to the Windows key on Windows and Linux and Cmd on macOS.
Command (or Cmd for short)Control (or Ctrl for short)CommandOrControl (or CmdOrCtrl for short)AltOptionAltGrShiftSuper0 to 9A to ZF1 to F24~, !, @, #, $, etc.PlusSpaceTabBackspaceDeleteInsertReturn (or Enter as alias)Up, Down, Left and RightHome and EndPageUp and PageDownEscape (or Esc for short)VolumeUp, VolumeDown and VolumeMuteMediaNextTrack, MediaPreviousTrack, MediaStop and MediaPlayPausePrintScreen