register-accelerator

0.0.1 • Public • Published

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)

Package Sidebar

Install

npm i register-accelerator

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

2.25 kB

Total Files

3

Last publish

Collaborators

  • coolstone
  • systemsoftware