electron: macOS: Accelerator doesn't call when MenuItem visible = false

  • Electron version: 1.3.8
  • Operating systems: macOS 10.12, Windows 10

If a MenuItem is not visible the keyboard shortcut doesn’t fire the Accelerator in macOS.

Here’s an snippet that works on Windows but not macOS:

{ label: 'Toggle Developer Tools',
    visible: false,
    accelerator: process.platform === 'darwin' ? 'Alt+Cmd+I' : 'Ctrl+Shift+I',
    click(item, browserWindow) {
        if (browserWindow) {
            browserWindow.webContents.toggleDevTools()
        }
    },
}

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

This behavior is actually expected on most platforms, we may need to explicitly document it.

Is there another way to use accelerator from Browser window without adding menu?

Yes, there’s https://github.com/parro-it/electron-localshortcut, a module to register/unregister a keyboard shortcut locally to a BrowserWindow instance, without using a Menu.