Normalize electron keyboard shortcuts so they work on different operating systems
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
README.mdt
example.js
index.js
keyboard.sketch
keyboard.svg
package.json
test.js

README.md

electron-shortcut-normalizer

Normalize electron keyboard shortcuts so they work on different operating systems.

shortcut

  • is a function
  • makes your electron keyboard shortcuts platform-agnostic
  • can make them platform-specific too
  • converts Option to Alt, because Alt exists on all platforms
  • converts CmdOrCtrl modifier to CommandOrControl
  • supports mixed-case modifiers like MediaPreviousTrack
  • capitalizes first letter of each modifier
  • removes whitespace from shortcuts
  • converts hyphens (-) to plusses (+)

Installation

npm install electron-shortcut-normalizer --save

Usage

const normalize = require("electron-shortcut-normalizer")

normalize('Ctrl+A')
// => 'CommandOrControl+A'

normalize('CommandOrControl+Z', process.platform)
// => 'Command+Z' on Mac OS X
// => 'Control+Z' on Windows and Linux

normalize('CmdOrCtrl+a', 'darwin')
// => 'Command+A'

normalize('CmdOrCtrl+a', 'win32')
// => 'Control+A'

// `Option` is unique to Mac OS X, so it's normalized to `Alt`:
normalize('Option+Up')
// => 'Alt+Up'

For more specific usage information, see test.js

See Also

Tests

npm install
npm 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