# electron-shortcut-normalizer

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

Latest version **1.0.0** (published 2016-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install electron-shortcut-normalizer
pnpm add electron-shortcut-normalizer
yarn add electron-shortcut-normalizer
bun add electron-shortcut-normalizer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-04-03 |
| First published | 2016-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Zeke Sikelianos |
| Maintainers | zeke |
| Keywords | electron, accelerator, shortcuts, keyboard, key, keycode |

## Links

- npm: https://www.npmjs.com/package/electron-shortcut-normalizer
- Repository: https://github.com/zeke/electron-shortcut-normalizer
- Homepage: https://github.com/zeke/electron-shortcut-normalizer#readme
- Issues: https://github.com/zeke/electron-shortcut-normalizer/issues
- npm.io page: https://npm.io/package/electron-shortcut-normalizer

## Recent versions

- 1.0.0 (latest) — 2016-04-03

## README

# electron-shortcut-normalizer

Normalize [electron keyboard shortcuts](https://github.com/atom/electron/blob/master/docs/api/accelerator.md#readme) so they work on different operating systems.

![shortcut](https://cloud.githubusercontent.com/assets/2289/14230694/9c80cc92-f916-11e5-921d-5dafbc8e5070.png)

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

## Installation

```sh
npm install electron-shortcut-normalizer --save
```

## Usage

```js
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](/test.js)

## See Also

- Electron [Accelerator](https://github.com/atom/electron/blob/master/docs/api/accelerator.md) docs
- Electron [Menu](https://github.com/atom/electron/blob/master/docs/api/menu.md) docs
- Electron [globalShortcut](https://github.com/atom/electron/blob/master/docs/api/global-shortcut.md) docs
- Node.js [process.platform](https://nodejs.org/api/process.html#process_process_platform) docs
- [electron-localshortcut](https://github.com/parro-it/electron-localshortcut), a module to register/unregister a keyboard shortcut locally to a BrowserWindow instance, without using a Menu.

## Tests

```sh
npm install
npm test
```

## Dependencies

None

## Dev Dependencies

- [tape](https://github.com/substack/tape): tap-producing test harness for node and browsers
- [tap-spec](https://github.com/scottcorgan/tap-spec): Formatted TAP output like Mocha&#39;s spec reporter


## License

MIT

_Generated by [package-json-to-readme](https://github.com/zeke/package-json-to-readme)_

---
_Source: https://npm.io/package/electron-shortcut-normalizer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
