我正在使用桌面应用程序,在Ubuntu服务器上工作时,我可以很好地阻止键盘快捷键:Alt+Tab,但是当我转移到Windows操作系统并尝试阻止Alt+Tab时,它不起作用。最大的问题在于Alt键,当我尝试在Windows 10上阻止它时,它严重地无法正常工作。
这里是我正在使用的代码:
var shortcutsToCapture = ['Ctrl+Alt+Delete', 'Alt+F4','CommandOrControl+A','Super+Alt+Tab','CommandOrControl+Shift+I', 'CommandOrControl+R']
// this should be placed at top of main.js to handle setup events quickly
if (handleSquirrelEvent(app)) {
// squirrel event handled and app will exit in 1000ms, so don't do anything else
return;
}
app.on('ready', function () {
captureShortcuts(shortcutsToCapture)
})
function captureShortcuts(shortcuts) {
shortcuts.forEach(function (shortcut) {
registerShortcutCapturing(shortcut)
})
}
function registerShortcutCapturing(shortcut) {
var result = globalShortcut.register(shortcut, function () {
console.log('<' + shortcut + '> captured!')
})
if (!result) {
console.log('<' + shortcut + '> registration failed!')
}
}
app.on('will-quit', () => {
// Unregister a shortcut.
globalShortcut.unregister('CommandOrControl+X')
// Unregister all shortcuts.
globalShortcut.unregisterAll()
})
'browser-window-blur'
发布一个答案呢?;) - pergy