我试图使用 Electron globalShortcut
模块来监听Ctrl-C
事件,但看起来, Electron 正在自动重写默认行为(没有像preventDefault
(纯 JavaScript)。
这就是我所做的:
app.whenReady().then(() => {
const test: boolean = globalShortcut.register('CommandOrControl+C', () => {
console.log('Test.')
})
/* ... */
})
是否有另一种方法可以使用 Electron 监听全局键盘快捷键事件而不中断其默认行为?
最佳答案
这似乎是Electron's expected behaviour
您可以使用iohook捕获按键而不是 Electron 的 globalShortcut
模块
关于javascript - 如何在不中断默认行为的情况下监听 Electron 中的键盘事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68509422/