register-accelerator
v0.0.1
Published
Register all accelerators in an Electron menu.
Downloads
1
Readme
Register Accelerator
Register all accelerators in an Electron menu.
Why?
Electron does not register accelerators in menus by default. This module fixes that by registering all accelerators in a menu.
How?
This module uses globalShortcut
to register all accelerators in a menu. It will not overwrite accelerators that are already registered, unless forced. Force overwrite by passing true
as the second argument to registerAccelerators
. Force overwriting is not recommended, as it can cause unexpected behavior.
Installation
npm install register-accelerator
Registering
const { app, Menu } = require('electron')
const registerAccelerators = require('register-accelerator')
const menu = Menu.getApplicationMenu()
const forceOverwrite = false
registerAccelerators(menu, forceOverwrite)
Unregistering
const { app, Menu } = require('electron')
const registerAccelerators = require('register-accelerator')
const menu = Menu.getApplicationMenu()
registerAccelerators.unregister(menu)