electron-shortcut-normalizer
Normalize electron keyboard shortcuts so they work on different operating systems.
- is a function
- makes your electron keyboard shortcuts platform-agnostic
- can make them platform-specific too
- accepts target
platform
in an options object - converts Option to Alt, because Alt exists on all platforms
- converts
CmdOrCtrl
modifier toCommandOrControl
- supports mixed-case modifiers like
MediaPreviousTrack
- capitalizes first letter of each modifier
- removes whitespace from shorcuts
- converts hyphens (-) to plusses (+)
Installation
npm install electron-shortcut-normalizer --save
Usage
const normalize = // => 'CommandOrControl+A' // => 'Command+Z' on Mac OS X// => 'Control+Z' on Windows and Linux // => 'Command+A' // => 'Control+A' // `Option` is unique to Mac OS X, so it's normalized to `Alt`:// => 'Alt+Up'
For more specific usage information, see test.js
See Also
- Electron Accelerator docs
- Electron Menu docs
- Electron globalShortcut docs
- Node.js process.platform docs
- electron-localshortcut, a module to register/unregister a keyboard shortcut locally to a BrowserWindow instance, without using a Menu.
Tests
npm installnpm test
Dependencies
None
Dev Dependencies
- tape: tap-producing test harness for node and browsers
- tap-spec: Formatted TAP output like Mocha's spec reporter
License
MIT
Generated by package-json-to-readme