All Projects → Graxi → vue2-shortcut

Graxi / vue2-shortcut

Licence: MIT License
Vue2.x plugin to create scoped or global shortcuts. No need to import a vue component into the template.

Programming Languages

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

Projects that are alternatives of or similar to vue2-shortcut

hotscript
HotScript - Revolutionizing how Windows works.
Stars: ✭ 29 (-23.68%)
Mutual labels:  shortcut, hotkey
react-hotkey-tooltip
A global Hotkey provider with built in tooltip for React
Stars: ✭ 34 (-10.53%)
Mutual labels:  shortcut, hotkey
Magnet
Customize global hotkeys in macOS.
Stars: ✭ 324 (+752.63%)
Mutual labels:  shortcut, hotkey
Keymage
Yet Another JS Keybinding library
Stars: ✭ 325 (+755.26%)
Mutual labels:  shortcut, hotkey
Xcactionbar
"Alfred for Xcode" plugin
Stars: ✭ 1,217 (+3102.63%)
Mutual labels:  shortcut, hotkey
react-shortcut
Convenient React component that detects if the given key combination is pressed, and triggers a callback
Stars: ✭ 16 (-57.89%)
Mutual labels:  shortcut, hotkey
hotkey
⌨️ cross-platform hotkey package
Stars: ✭ 82 (+115.79%)
Mutual labels:  shortcut, hotkey
Hotkeys
➷ A robust Javascript library for capturing keyboard input. It has no dependencies.
Stars: ✭ 5,165 (+13492.11%)
Mutual labels:  shortcut, hotkey
Capslock Plus
An efficiency tool that provides various functions by enhancing the Caps Lock key into a modifier key.
Stars: ✭ 650 (+1610.53%)
Mutual labels:  shortcut, hotkey
keybind
ClojureScript key bindings (shortcut) library
Stars: ✭ 85 (+123.68%)
Mutual labels:  shortcut, hotkey
apptivator
A macOS menubar app which activates applications via global shorcuts ⌨️
Stars: ✭ 72 (+89.47%)
Mutual labels:  shortcut, hotkey
micSwitch
macOS menu bar application for the mic mute/unmute with single click or shortcut with walkie-talkie style support
Stars: ✭ 37 (-2.63%)
Mutual labels:  shortcut
dida
⚡️ Easily add task to 滴答清单(TickTick) by shortcut
Stars: ✭ 43 (+13.16%)
Mutual labels:  shortcut
swhkd
Sxhkd clone for Wayland (works on TTY and X11 too) | mirrored at https://git.sr.ht/~shinyzenith/swhkd
Stars: ✭ 215 (+465.79%)
Mutual labels:  hotkey
nvim
❤️ A neovim config repo.
Stars: ✭ 33 (-13.16%)
Mutual labels:  shortcut
executor
A powerful "short-cutter" to your console to you and your team!
Stars: ✭ 21 (-44.74%)
Mutual labels:  shortcut
vue-hotkey
Simple Vue Hotkey
Stars: ✭ 20 (-47.37%)
Mutual labels:  hotkey
lifer
Windows link file forensic examiner
Stars: ✭ 58 (+52.63%)
Mutual labels:  shortcut
dxhd
daky's X11 Hotkey Daemon
Stars: ✭ 80 (+110.53%)
Mutual labels:  hotkey
SwitchCaseGenerator
An Xcode Source Editor Extension that generates a swift switch case statement based on selected enum cases
Stars: ✭ 63 (+65.79%)
Mutual labels:  shortcut

vue2-shortcut

Vue2.x plugin to create scoped or global shortcuts. No need to import a vue component into the template.

AppVeyor

Codacy Badge

Install

$ npm install --save vue2-shortcut

Usage

import Vue from 'vue';
import vShortcut from 'vue2-shortcut';
Vue.use(vShortcut);

Optional global config

You can define excludeTags or customized preventWhen function globally to prevent shortcuts from being executed

  • excludeTags: a list of html tags where shortcuts should not be triggered
  • preventWhen: a global interceptor function which returns true
  Vue.use(vShortcut, {
    excludeTags: ['input', 'textarea'],
    preventWhen: (e) => true // prevents all shortcuts
  })

Check the demo here

Define scopes for shortcuts

By default, the shorcuts will work globally. Optionally, if you want to restrict shorcuts within certain scopes, it's also easy to define a scope in vue template like this:

  <div v-shortcut-scope="'a'">
    Component A
  </div>

Then you could pass ['a'] as value for the scope property when creating shortcuts. In this way, shorcuts are triggered only when you are currently interacting with Component A

Register shortcuts

Register your shortcuts in any vue template under the mounted hook

  mounted() {
    Vue.createShortcuts(this, [
      {
        keys: ['ctrl', 'c'],
        scope: ['a'], // optional
        eventHandler: () => {
          console.log('pressing ctrl and c in scope a');
          console.log('executed once');
        },
        once: true, // optional, false by default
        unordered: true // optional, false by default
      }
    ])
  }

Deregister shortcuts

When the template is destroyed, shortcuts registered in that template will be removed automatically

Key List

Below is the list of keys mapping. Use ctrl if you want a shortcut to work with meta on mac and control on windows.

Keyboard shortcut key
A - Z a - z
0 - 9 0 - 9
F1 - F12 f1 - f12
Escape esc
Backquote backquote
Minus minus
Equal equal
Backspace del
Tab tab
CapsLock capslock
Space space
Pause pause
Delete del
ContextMenu contextmenu
BracketLeft bracketleft
BracketRight bracketright
Backslash backslash
Semicolon semicolon
Quote quote
Enter enter
Comma comma
Period period
Slash slash
ArrowLeft arrowleft
ArrowUp arrowup
ArrowRight arrowright
ArrowDown arrowdown
Control control
Shift shift
Alt alt
Meta meta
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].