快捷键可以包含多个功能键和一个键码的字符串,由符号+结合,用来定义你应用中的键盘快捷键
globalShortcut.register(shortcutStr,EventHandler)
示例
CommandOrControl+ACommandOrControl+Shift+Z快捷方式使用 register 方法在 globalShortcut 模块中注册, 即:
const { app, globalShortcut } = require(‘electron‘)
app.whenReady().then(() => {
// 注册一个‘CommandOrControl+Y‘ 快捷键监听.
globalShortcut.register(‘CommandOrControl+Y‘, () => {
// Do stuff when Y and either Command/Control is pressed.
})
})
在 Linux 和 Windows 上, Command 键没有任何效果, 所以使用 CommandOrControl表述, macOS 是 Command ,在 Linux 和 Windows 上是Control。
使用 Alt按键替代 Option按键。 使用 Alt 键代替Option. Option 键只在 macOS 系统上存在, 而 Alt 键在任何系统上都有效.
Super键是指 Windows 和 Linux 系统上的 Windows 键,但在 macOS 里为 Cmd 键.
Command (缩写为Cmd)Control (缩写为Ctrl)CommandOrControl (缩写为 CmdOrCtrl)AltOptionAltGrShiftSuper0 到 9A 到 ZF1 到 F24~, !, @, #, $, etc.PlusSpaceTab大写锁定(Capslock)数字锁定(Numlock)滚动锁定BackspaceDeleteInsertReturn (等同于 Enter)Up, Down, Left and RightHome 和 EndPageUp 和 PageDownEscape (缩写为 Esc)VolumeUp, VolumeDown 和 VolumeMuteMediaNextTrack、MediaPreviousTrack、MediaStop 和 MediaPlayPausePrintScreennum1-num9 -数字1-数字9numdec - 小数点numadd - 加号numsub - 减号nummult - 乘号numdiv - 除号原文:https://www.cnblogs.com/baixinL/p/14274761.html