Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-localshortcut

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-localshortcut

register/unregister a keyboard shortcut locally to a BrowserWindow instance, without using a Menu

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31K
decreased by-5.37%
Maintainers
1
Weekly downloads
 
Created
Source

electron-localshortcut

A module to register/unregister a keyboard shortcut locally to a BrowserWindow instance, without using a Menu.

NPM module NPM downloads

Installation

npm install --save electron-localshortcut

Usage

  const electronLocalshortcut = require('electron-localshortcut');
  const BrowserWindow = require('browser-window');

  const win = new BrowserWindow();
  win.loadUrl('https://github.com');
  win.show();

  electronLocalshortcut.register(win, 'Ctrl+A', () => {
    console.log('You pressed ctrl & A');
  });

  electronLocalshortcut.register(win, 'Ctrl+B', () => {
    console.log('You pressed ctrl & B');
  });

  console.log(
    electronLocalshortcut.isRegistered(win, 'Ctrl+A')
  );      // true

  electronLocalshortcut.unregister(win, 'Ctrl+A');
  electronLocalshortcut.unregisterAll(win);


Methods

The electron-localshortcut module has following methods:

register(window, accelerator, callback)

  • window BrowserWindow instance
  • accelerator Accelerator
  • callback Function

Registers a shortcut of accelerator on the window BrowserWindow instance. The callback is called when the registered shortcut is pressed by the user, only if window is focused.

isRegistered(window, accelerator)

Returns true or false depending on whether the shortcut accelerator is registered on window.

unregister(window, accelerator)

Unregisters the shortcut of accelerator registered on the BrowserWindow instance.

unregisterAll(window)

  • window BrowserWindow instance

Unregisters all of the shortcuts registered on the BrowserWindow instance.

License

The MIT License (MIT)

Copyright (c) 2015 Andrea Parodi

Keywords

FAQs

Package last updated on 03 Nov 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc