fabiospampinato / Shortcuts
Licence: mit
Super performant and feature rich shortcuts management library.
Stars: ✭ 40
Programming Languages
typescript
32286 projects
Labels
Projects that are alternatives of or similar to Shortcuts
quickreview-for-github
Reviewing 50+ Pull Requests a day is no fun. Automate it with keyboard shortcuts.
Stars: ✭ 28 (-30%)
Mutual labels: shortcuts
puffery
A SwiftUI iOS App and Vapor Server to send push notifications fueled by Siri Shortcuts.
Stars: ✭ 17 (-57.5%)
Mutual labels: shortcuts
Passepartout Apple
User-friendly OpenVPN client app for iOS and macOS.
Stars: ✭ 284 (+610%)
Mutual labels: shortcuts
Sublimetutor
An interactive in-editor keyboard shortcuts tutorial for Sublime Text 3
Stars: ✭ 336 (+740%)
Mutual labels: shortcuts
Better Chrome Native Video
Add keyboard support to Chrome's native HTML5 video player.
Stars: ✭ 31 (-22.5%)
Mutual labels: shortcuts
Coffeescript Sublime Plugin
Syntax highlighting and checking, commands, shortcuts, snippets, compilation and more.
Stars: ✭ 296 (+640%)
Mutual labels: shortcuts
Hotkeys
➷ A robust Javascript library for capturing keyboard input. It has no dependencies.
Stars: ✭ 5,165 (+12812.5%)
Mutual labels: shortcuts
react-keyboard-shortcuts
A declarative library for handling hotkeys based on explicit priority in React applications
Stars: ✭ 23 (-42.5%)
Mutual labels: shortcuts
Electron Localshortcut
Add keyboard shortcuts locally to a BrowserWindow instance, without using a Menu
Stars: ✭ 366 (+815%)
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 (-67.5%)
Mutual labels: shortcuts
Shortcutmapper
A visual keyboard shortcuts explorer for popular applications.
Stars: ✭ 657 (+1542.5%)
Mutual labels: shortcuts
Spotify Shortcuts Ios12
This repository contains a list of all available Shortcuts to control Spotify as well as an update mechanism.
Stars: ✭ 34 (-15%)
Mutual labels: shortcuts
Shortcuts
Super performant and feature rich shortcuts management library.
Features
- Super performant: it's about as fast as it gets, I don't think it's possible to do significantly better than this.
- Sequences support: sequences (a.k.a. konami codes), are supported too, so you can bind actions to Up Right Down Left or whatever shortcuts sequence you want.
- Shortcut to Accelerator: supported shortcuts can be converted to their Electron's Accelerator equivalent.
-
Shortcut to symbols: supported shortcuts can be converted to symbols (e.g.
⌘A
), this is useful for providing shortcut hints in tooltips.
Install
npm install --save shortcuts
Usage
This library provides a Shortcuts
class, which will manage your shortcuts, and a Shortcut
object, which provides some utilities.
Shortcut Syntax
The following keys can be used when defining a shortcut:
- Modifiers: Alt/Option, Cmd/Command/Meta, Ctrl/Control, Shift, CmdOrCtrl/CommandOrControl.
- Digits: 1-9.
- Alphabet letters: A-Z.
- Function keys: F1-F24.
- Numpad digits: Numpad0-Numpad9.
- Special keys: Backspace, Capslock, Del/Delete, Down, End, Enter/Return, Esc/Escape, Home, Insert, Left, PageDown, PageUp, Right, Space/Spacebar, Tab, Up.
- Punctuation keys: !, ", #, $, %, &, ', (, ), *, +/plus, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, ~.
Other keys are not supported.
- ℹ️ Shortcuts are case insensitive.
- ℹ️ Keys in a single shortcut must be joined by a plus sign (e.g. Ctrl+A).
- ℹ️ Sequences of shortcuts must be joined by a space (e.g. Ctrl+K Ctrl+B).
Shortcuts Class
The Shortcuts class will be used for adding/removing/resetting/recording shortcuts. This is its interface:
class Shortcuts {
constructor ( options?: { shortcuts?: ShortcutDescriptor[]: capture?: boolean, target?: Node, shouldHandleEvent?: event => boolean } );
get (): ShortcutDescriptor[];
add ( descriptors: ShortcutDescriptor | ShortcutDescriptor[] );
remove ( descriptors: ShortcutDescriptor | ShortcutDescriptor[] );
reset ();
record ( handler: ( shortcut ) => any ): Function;
}
- ℹ️ The
shortcuts
option accepts an optional array of shortcuts descriptors. More on this below. - ℹ️ The
capture
option governs whether events are attached for the capturing phase or for the bubbling phase of the propagation. - ℹ️ The
target
option accepts an optional DOM node, where the keyboard evenr listener will be attached to. - ℹ️ The
shouldHandleEvent
option accepts an optional function which will be used for determining, for each keyboard event, if it should be handled by this library. By default that function is:event => !event.defaultPrevented
.
A shortcut descriptor looks like this:
{
handler?: ( event: KeyboardEvent ) => boolean | void,
shortcut: string
}
Usage:
import {Shortcuts} from 'shortcuts';
const shortcuts = new Shortcuts ();
function CtrlBHandler () {};
shortcuts.add ([ // Adding some shortcuts
{ shortcut: 'Ctrl+A', handler: event => {
console.log ( event );
return true; // Returning true because we don't want other handlers for the same shortcut to be called later
}},
{ shortcut: 'Ctrl+B', handler: CtrlBHandler },
{ shortcut: 'CmdOrCtrl+K Shift+B', handler: () => {
// Doing something...
return true; // Returning true because we don't want other handlers for the same shortcut to be called later
}},
{ shortcut: '-Ctrl+A' } // Removing the previous shortcut
]);
shortcuts.remove ({ shortcut: 'Ctrl-B', handler: CtrlBHandler }); // Removing a single handler
shortcuts.remove ({ shortcut: 'Ctrl-A' }); // Removing all handlers bound to this shortcut
shortcuts.reset (); // Removing all shortcuts
const dispose = shortcuts.record ( shortcut => { // Recording shortcuts
console.log ( 'Shortcut recorded:', shortcut );
});
dispose (); // Stopping recording
- ℹ️ Handlers are called from the bottom to the top, so an handler defined at the bottom will take precedence over an handler for the same shortcut defined at the top.
- ℹ️ If multiple handlers are defined for the same shortcut all of them are executed until one of them returns
true
. - ℹ️ Adding a shortcut starting with an hyphen (e.g.
-Ctrl-A
) will actually remove that shortcut. - ℹ️ While recording no handlers will be called.
Shortcut Object
The Shortcut object provides some utilities that you might need in your application. This is its interface:
const Shortcut = {
shortcut2id ( shortcut: string ): number[];
shortcut2accelerator ( shortcut: string ): string;
shortcut2symbols ( shortcut: string ): string;
};
Usage:
import {Shortcut} from 'shortcuts';
Shortcut.shortcut2accelerator ( 'Meta+Del' ); // => 'Cmd+Delete'
Shortcut.shortcut2symbols ( 'Cmd+Shift+A' ); // => '⌘⇧A'
Thanks
- Thanks to the people at Koding for providing me the
shortcuts
package name on NPM! If you're looking for the previous package published under that name you can find it here (v0.x
).
License
MIT © Fabio Spampinato
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].