All Projects β†’ coosto β†’ ShortcutJS

coosto / ShortcutJS

Licence: Apache-2.0 license
Keyboard manager for javascript and typescript, made for humans 😎

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to ShortcutJS

Pretzel
Pretzel is Mac desktop app that shows and find keyboard shortcuts based on your current app.
Stars: ✭ 405 (+1457.69%)
Mutual labels:  keyboard, shortcut
Hotkey
Simple global shortcuts in macOS
Stars: ✭ 574 (+2107.69%)
Mutual labels:  keyboard, shortcut
React Hotkeys
React component to listen to keydown and keyup keyboard events, defining and dispatching keyboard shortcuts.
Stars: ✭ 279 (+973.08%)
Mutual labels:  keyboard, shortcut
hotscript
HotScript - Revolutionizing how Windows works.
Stars: ✭ 29 (+11.54%)
Mutual labels:  keyboard, shortcut
Ng Keyboard Shortcuts
Dead Simple Keyboard Shortcuts Management for Angular
Stars: ✭ 121 (+365.38%)
Mutual labels:  keyboard, shortcut
g910-gkey-macro-support
GKey support for Logitech G910 Keyboard on Linux
Stars: ✭ 85 (+226.92%)
Mutual labels:  keyboard, shortcut
Hotkeys
➷ A robust Javascript library for capturing keyboard input. It has no dependencies.
Stars: ✭ 5,165 (+19765.38%)
Mutual labels:  keyboard, shortcut
Capslock Plus
An efficiency tool that provides various functions by enhancing the Caps Lock key into a modifier key.
Stars: ✭ 650 (+2400%)
Mutual labels:  keyboard, shortcut
Globalhooks
Allows you to create global keyboard events
Stars: ✭ 74 (+184.62%)
Mutual labels:  keyboard, shortcut
Slowquitapps
Add a global delay to Command-Q to stop accidental app quits.
Stars: ✭ 916 (+3423.08%)
Mutual labels:  keyboard, shortcut
metaKeyboard
turn a common keyboard into a 61-key keyboard for the keyboard shortcut fun like you, I'm a programer, I want to improve coding efficiency
Stars: ✭ 30 (+15.38%)
Mutual labels:  keyboard, shortcut
Selectnextoccurrence
A Visual Studio Extension that selects the next occurrences of the current selection and adds multiple cursors for editing
Stars: ✭ 129 (+396.15%)
Mutual labels:  keyboard, shortcut
hotkey
⌨️ cross-platform hotkey package
Stars: ✭ 82 (+215.38%)
Mutual labels:  keyboard, shortcut
SwitchCaseGenerator
An Xcode Source Editor Extension that generates a swift switch case statement based on selected enum cases
Stars: ✭ 63 (+142.31%)
Mutual labels:  shortcut
ng-virtual-keyboard
Virtual Keyboard for Angular applications
Stars: ✭ 25 (-3.85%)
Mutual labels:  keyboard
react-keyview
React components to display the list, table, and grid, without scrolling, use the keyboard keys to navigate through the data
Stars: ✭ 16 (-38.46%)
Mutual labels:  keyboard
lumberjack-keyboard
5x12 ortholinear through-hole component keyboard PCB for standard 60% cases
Stars: ✭ 231 (+788.46%)
Mutual labels:  keyboard
Arduino-Chunithm-Controller
使用 Arduino εˆΆδ½œηš„ Chunithm ζŽ§εˆΆε™¨γ€‚
Stars: ✭ 29 (+11.54%)
Mutual labels:  keyboard
android-shortcut-gradle-plugin
Android Gradle plugin generates App Shortcuts shortcuts.xml for different flavors with different applicationId.
Stars: ✭ 20 (-23.08%)
Mutual labels:  shortcut
kalamine
Keyboard Layout Maker
Stars: ✭ 47 (+80.77%)
Mutual labels:  keyboard

ShortcutJS

npm Travis Coverage Status bitHound Code bitHound Dependencies npm

Keyboard manager for javascript and typescript, made for humans 😎

Do you have a very interactive app with lots of shortcuts? ShortcutJS makes defining all your shortcuts very easy, by defining Combos bound to Actions. Even better, you can define them all in JSON file.

Usage

yarn add shortcutjs
# or
npm install shortcutjs --save

Define a shortcuts.json file with all your shortcuts

[
  {
    "combo": "ctrl a",
    "action": "selectAll"
  },
  {
    "combo": "ctrl alt f",
    "action": "find"
  }
]

Note: action means just an action name to subscribe to

// --> main.js
import { shortcutJS } from 'shortcutjs'
import shortcuts from './shortcuts.json'

// optional debug param
shortcutJS.fromJson(shortcuts, { debug: true })


// --> yourComponent.js (any other file)
import { shortcutJS } from 'shortcutjs'

// Subscribe to the action created from the json
shortcutJS.subscribe('selectAll', ev => console.log('ctrl a have been triggered!', ev))

Checkout the Full API documentation

Combos and Supported keys

A combo is composed by 1 or more state keys (ctrl, alt, shift, cmd) plus 1 or more supported keys. They're case insensitive.

Supported keys:

  • Basic letters (a-z)
  • Numbers (0-9)
  • Navigation keys (left, up, enter, backspace, end...)
  • Function keys (f1, f2...)
  • Numpad keys (num0, num1, num*, num/...)

You can see all available keys in keyMap of key-container.ts.

Options

When initializing shortcutJS by calling fromJson or init, you can pass an options object:

{
  debug: false, // Prints debug notes in the console
  preventDefault: false, // Automatically calls ev.preventDefault() when an action is matched
  onlyStateCombos: false, // Only process combos which includes any state key (cmd, ctrl, alt, shift)
}

API

  • fromJson(json[], options): initializes shortcutJS from a json array
  • subscribe(actionName, cb): binds a callback to an action, given its name
  • unsubscribe(actionName, cb?): unbinds a callback from an action, given its name. If no cb specified, unbinds all.
  • pause(): pauses execution of shortcutJS
  • resume()
  • isPaused()
  • addAction(action: Action): dynamically adds an action
  • init(options): (don't use it if you've used fromJson). Initializes shortcutJS.
  • reset(): resets shortcutJS, cleans variables and unbind events

Examples

When loading from json, you only need to use fromJson, subscribe and unsubscribe methods.

Pausing/Resuming

import { shortcutJS } from 'shortcutjs'
import shortcuts from './shortcuts.json'

shortcutJS.fromJson(shortcuts)

shortcutJS.pause()
console.log(shortcutJS.isPaused()) // true
shortcutJS.resume()
console.log(shortcutJS.isPaused()) // false

Manually creating Actions and Combos

import { shortcutJS, Action, KeyCombo } from 'shortcutjs'

shortcutJS.init({ debug: true }) // optional "options" parameter

// Add action
const openAction = new Action('open', KeyCombo.fromString('ctrl a'))
shortcutJS.addAction(openAction)

// --> From anotherComponent.js
const openCb = ev => console.log(ev)
shortcutJS.subscribe('open', openCb)

// Later, when leaving the view...
shortcutJS.unsubscribe('open', openCb)

Contribution guide

# Fork repo
git clone https://github.com/YOUR-USERNAME/ShortcutJS
yarn install # or npm install
# Start coding. For commit, use npm run commit (otherwise it will tell you to do it ;)
# Open a PR

Note: Use node 7.5, or <= 7.2. Because of a regression in Node 7.3, the tests would fail in Node 7.3 and 7.4

ShortcutJS project setup applies CI (with Travis) + CD (Semantic Release) using conventions (commitizen, with conventional-commit and conventional-changelog) and git hooks instead of large contribution rules.

As a suggestion, follow clean code practises

Credits

Made with ❀️ by @alexjoverm, supported by Coosto, @coostodev

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].