Socket
Socket
Sign inDemoInstall

keyboardevent-from-electron-accelerator

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    keyboardevent-from-electron-accelerator

Transform an Electron Accelerator string into a DOM KeyboardEvent.


Version published
Weekly downloads
29K
decreased by-6.34%
Maintainers
1
Install size
12.2 kB
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 08 Nov 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc