GitXplorerGitXplorer
p

keyboardevent-from-electron-accelerator

public
14 stars
7 forks
12 issues

Commits

List of commits on branch master.
Unverified
566a2f92f1eab4f9e355c99e36c1d6dcc6dfa57f

2.0.0

committed 5 years ago
Unverified
242d35a82ad665cb5d4f99345076223c12de8e0d

1.2.0

committed 5 years ago
Unverified
1665f4615edc4df0fed28cd4339031acc271a992

Fixed space

committed 5 years ago
Unverified
40e759dfdaf3ba462273400c2571f37cbb113a83

bump version, removed rollup

committed 5 years ago
Verified
afdbd57bead1e139d7bd03c763778dce6ca8c35d

Merge pull request #12 from XanderEmu/master

pparro-it committed 7 years ago
Unverified
b6c93e2cbb8112ca720b84c0366da79179497e9f

Fix test cases for 'Command shortcuts are not converted on Windows and Linux' and 'Options shortcuts are not converted on Windows and Linux'

committed 7 years ago

README

The README file for this repository.

keyboardevent-from-electron-accelerator

Travis Build Status NPM downloads AppVeyor Build status

Transform an Electron Accelerator string into a DOM KeyboardEvent.

This module export a function that take an Electron Accelerator as input and return a corresponding KeyboardEvent object.

E.g. 'Ctrl+Alt+C' => {code: 'c', ctrlKey: true, altKey: true}

Usage

This example convert a string containing an Electron Accelerator to a corresponding KeyboardEvent object. Returned object is the keyevent that would be emitted if that key combination was pressed.

const {toKeyEvent} = require('keyboardevent-from-electron-accelerator');
console.log(toKeyEvent('Shift+Delete'));

This will output

{key: 'Delete', shiftKey: true}

Context and motivation for this module.

This module is part of an ongoing effort to make electron-localshortcut less error prone, using keyboard DOM listener instead of 'globalShortcut' method to trigger shortcuts handlers.

electron-localshortcut will listen for DOM keydown and keyup events, and will trigger shortcuts handlers if emitted DOM events match the Accelerator.

This module wrap the core logic of that match operation.

You can help by testing the module on runkit and opening an issue if you found some wrong result.

API

toKeyEvent

This function transform an Electron Accelerator string into a DOM KeyboardEvent object.

Parameters

  • accelerator string an Electron Accelerator string, e.g. Ctrl+C or Shift+Space.

Returns object a DOM KeyboardEvent object derivate from the accelerator argument.

Install

With npm installed, run

$ npm install keyboardevent-from-electron-accelerator

See Also

License

MIT