Formats an accelerator as a string of Unicode characters.
Handles Windows and Mac, not yet Linux.
Works in both Electron (i.e. Node) and the browser!
For Electron:
npm install electron-accelerator-formatter
or
npm install electron-accelerator-formatter --save
For the browser:
bower install electron-accelerator-formatter --save
In Electron:
var acceleratorFormatter = require('electron-accelerator-formatter');
var accelerator = 'CmdOrCtrl+Shift+M';
// Prints '⌘⇧M' on Mac, '^⇧M' on Windows
console.log(acceleratorFormatter(accelerator));
In the browser:
<!-- Loads `electronAcceleratorFormatter` into `window`. See warning below about minified version. -->
<script src="bower_components/electron-accelerator-formatter/dist/bundle.js"></script>
<script type="text/javascript">
var accelerator = 'CmdOrCtrl+Shift+M';
// Prints '⌘⇧M' on Mac, '^⇧M' on Windows
console.log(electronAcceleratorFormatter(accelerator));
</script>
Warning: there is also a minified version available, dist/bundle.min.js
, but if you want to use
that make sure that you are sending the UTF-8 HTTP header from your server or have added <meta charset="UTF-8">
to the page, or the formatter output will be garbled: webpack/webpack#1035.
We welcome pull requests! Please lint your code.
To run the Node tests: npm test
.
To run the browser tests: npm run-script build-test && npm run-script open-test
.
npm run-script build
- 1.1.1 Add bower.json file
- 1.1.0 Works in the browser!
- 1.0.1 Documentation fix
- 1.0.0 Initial release.