注册全局键盘Shotcut

时间:2016-10-31 10:41:35

标签: electron

我最近正在使用Github的Electron文档。他们使用的一个例子

const electron = require('electron') const app = electron.app const dialog = electron.dialog const globalShortcut = electron.globalShortcut

app.on('ready', function () {   globalShortcut.register('CommandOrControl+Alt+K', function () {
    dialog.showMessageBox({
      type: 'info',
      message: 'Success!',
      detail: 'You pressed the registered global shortcut keybinding.',
      buttons: ['OK']
    })   }) })

app.on('will-quit', function () {   globalShortcut.unregisterAll() })

这似乎是键盘挂钩的跨平台解决方案。但是上面的示例全局注册键盘快捷键。有可能以一种方式记录所有击键而不会妨碍用户吗?例如,如果我要按。我的网络浏览器上的'ctrl + w'我希望我的电子应用程序注册ctrl + w。但并不妨碍它在weeb浏览器上的功能。

有可能吗?

1 个答案:

答案 0 :(得分:2)

由于安全性和可用性问题,Electron团队已经考虑了此功能的可能实施,并拒绝了a related github issue 赢得