All Projects → parro-it → Electron Localshortcut

parro-it / Electron Localshortcut

Licence: mit
Add keyboard shortcuts locally to a BrowserWindow instance, without using a Menu

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Electron Localshortcut

Xcactionbar
"Alfred for Xcode" plugin
Stars: ✭ 1,217 (+232.51%)
Mutual labels:  shortcut, shortcuts
Hotkeys
➷ A robust Javascript library for capturing keyboard input. It has no dependencies.
Stars: ✭ 5,165 (+1311.2%)
Mutual labels:  shortcut, shortcuts
Keymage
Yet Another JS Keybinding library
Stars: ✭ 325 (-11.2%)
Mutual labels:  shortcut, shortcuts
executor
A powerful "short-cutter" to your console to you and your team!
Stars: ✭ 21 (-94.26%)
Mutual labels:  shortcut, shortcuts
react-shortcut
Convenient React component that detects if the given key combination is pressed, and triggers a callback
Stars: ✭ 16 (-95.63%)
Mutual labels:  shortcut, shortcuts
static-hands
⌨️🤯 Stop moving hands, and start code fast ⚡⚡
Stars: ✭ 36 (-90.16%)
Mutual labels:  shortcut, shortcuts
Python Shortcuts
Create Siri Shortcuts with Python
Stars: ✭ 525 (+43.44%)
Mutual labels:  shortcut, shortcuts
keybind
ClojureScript key bindings (shortcut) library
Stars: ✭ 85 (-76.78%)
Mutual labels:  shortcut, shortcuts
hotkey
⌨️ cross-platform hotkey package
Stars: ✭ 82 (-77.6%)
Mutual labels:  shortcut, shortcuts
Androidshortcuts
Example app for shortcuts
Stars: ✭ 335 (-8.47%)
Mutual labels:  shortcut, shortcuts
vue2-shortcut
Vue2.x plugin to create scoped or global shortcuts. No need to import a vue component into the template.
Stars: ✭ 38 (-89.62%)
Mutual labels:  shortcut
puffery
A SwiftUI iOS App and Vapor Server to send push notifications fueled by Siri Shortcuts.
Stars: ✭ 17 (-95.36%)
Mutual labels:  shortcuts
Passepartout Apple
User-friendly OpenVPN client app for iOS and macOS.
Stars: ✭ 284 (-22.4%)
Mutual labels:  shortcuts
ShortcutMapper Chinese
可视化、交互式的快捷键映射图,中文版本,可以直观地查找快捷键。不懂编程也可以方便地修改、添加快捷键。
Stars: ✭ 23 (-93.72%)
Mutual labels:  shortcut
Shortcuts
自动养猫|自动淘金币|自动欢乐造|抢购助手|快捷指令
Stars: ✭ 283 (-22.68%)
Mutual labels:  shortcuts
shortcuts es
Información en español sobre los atajos ("shortcuts") de iOS. Asociado a la comunidad @shortcuts_es en Telegram.
Stars: ✭ 13 (-96.45%)
Mutual labels:  shortcuts
react-hotkey-tooltip
A global Hotkey provider with built in tooltip for React
Stars: ✭ 34 (-90.71%)
Mutual labels:  shortcut
quickreview-for-github
Reviewing 50+ Pull Requests a day is no fun. Automate it with keyboard shortcuts.
Stars: ✭ 28 (-92.35%)
Mutual labels:  shortcuts
Sublimetutor
An interactive in-editor keyboard shortcuts tutorial for Sublime Text 3
Stars: ✭ 336 (-8.2%)
Mutual labels:  shortcuts
Magnet
Customize global hotkeys in macOS.
Stars: ✭ 324 (-11.48%)
Mutual labels:  shortcut

electron-localshortcut

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

This is built to circumvent this Electron issue.

Travis Build Status NPM module NPM downloads Greenkeeper badge

Installation

npm install --save electron-localshortcut

Usage

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

	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');
	});

	electronLocalshortcut.register(win, ['Ctrl+R', 'F5'], () => {
        console.log('You pressed ctrl & R or F5');
    });

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

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

App shortcuts.

If you omit the window argument of isRegistered, unregisterAll, unregister and register methods, the shortcut is registered as an app shortcut. It is active when any window of the app is focused.

They differ from native global-shortcuts because they doesn't interfere with other apps running on the same machine.

Shortcut behaviour.

If you register a shortcut for a window, this module unregister the shortcut when the window is hidden, unfocused or minimized, and automatically restore it when the window is restored and focused again.

If you register an app shortcut, this module unregister the shortcut when all windows of your app are hidden, unfocused or minimized, and automatically restore it when any window of your app is restored and focused again.

API

disableAll

Disable all of the shortcuts registered on the BrowserWindow instance. Registered shortcuts no more works on the window instance, but the module keep a reference on them. You can reactivate them later by calling enableAll method on the same window instance.

Parameters

  • win BrowserWindow BrowserWindow instance

Returns Undefined

enableAll

Enable all of the shortcuts registered on the BrowserWindow instance that you had previously disabled calling disableAll method.

Parameters

  • win BrowserWindow BrowserWindow instance

Returns Undefined

unregisterAll

Unregisters all of the shortcuts registered on any focused BrowserWindow instance. This method does not unregister any shortcut you registered on a particular window instance.

Parameters

  • win BrowserWindow BrowserWindow instance

Returns Undefined

register

Registers the shortcut acceleratoron the BrowserWindow instance.

Parameters

  • win BrowserWindow BrowserWindow instance to register. This argument could be omitted, in this case the function register the shortcut on all app windows.
  • accelerator (String | Array<String>) the shortcut to register
  • callback Function This function is called when the shortcut is pressed and the window is focused and not minimized.

Returns Undefined

unregister

Unregisters the shortcut of accelerator registered on the BrowserWindow instance.

Parameters

  • win BrowserWindow BrowserWindow instance to unregister. This argument could be omitted, in this case the function unregister the shortcut on all app windows. If you registered the shortcut on a particular window instance, it will do nothing.
  • accelerator (String | Array<String>) the shortcut to unregister

Returns Undefined

isRegistered

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

Parameters

  • win BrowserWindow BrowserWindow instance to check. This argument could be omitted, in this case the function returns whether the shortcut accelerator is registered on all app windows. If you registered the shortcut on a particular window instance, it return false.
  • accelerator String the shortcut to check

Returns Boolean if the shortcut accelerator is registered on window.

License

The MIT License (MIT)

Copyright (c) 2017 Andrea Parodi

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].