作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法禁用或更改Electron中这些键盘快捷键的工作。
Ctrl + Alt + Delete和Alt + F4
下面,我提到了进行此更改的2种不同代码。
const { app, BrowserWindow, globalShortcut, path, url} = require('electron')
app.on('ready', () => {
const ret = globalShortcut.register('alt+f4', function () {
win.show()
})
})
{
role: 'help',
submenu: [
{
label: 'Reload',
accelerator: 'Alt + F4',
click: function (item, focusedWindow) {
focusedWindow.reload();
}
}
]
}
最佳答案
您可以通过阻止keydown
进程中的renderer
事件来禁用它
window.addEventListener('keydown', (e) => {
const { key, altKey } = e;
if (key === 'F4' && altKey) {
e.preventDefault();
}
});
关于javascript - 如何在ElectronJS中禁用键盘快捷方式 'Alt + F4',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55296837/
我是一名优秀的程序员,十分优秀!