Socket
Book a DemoInstallSign in
Socket

@grandchef/vue-keybindings

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@grandchef/vue-keybindings

Keyboard Shortcuts registration and Keybindings management

2.0.2
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

Vue-Keybindings

NPM version VueJS v3 compatible Downloads License

Keyboard Shortcuts registration and Keybindings management

Install

yarn add @grandchef/vue-keybindings

or

npm install @grandchef/vue-keybindings --save

Usage

Configuration

import VueKeybindings from '@grandchef/vue-keybindings'

Vue.use(VueKeybindings, {
    alias: {
        cancel: ['esc'],
        reload: ['alt', 'f5'],
        delete: 'shift+del'
    }
})

On Vuejs instance usage

var vm = new Vue({
  shortcuts: {
    keydown: function (event) {
      console.log('key ', event, 'pressed')
      return false // stop alias calling
    },
    cancel: function () {
      console.log('escape key pressed')
      return false // stop propagation
    },
    customBinding: function (data) {
      console.log('this method was fired by some call to: vm.$shortcut.emit("customBinding", data)')
    }
  },
  methods: {
    clickButton: function (val) {
        this.$shortcut.emit('customBinding', val)
    }
  }
})

Dynamic shortcut event listeners

Create a new listener

this.$options.shortcuts.commandName = () => {
    console.log('do some action')
}

Remove existing listener

delete this.$options.shortcuts.commandName;

Dynamic shortcut registration

Create a new keybinding

this.$shortcut.add('command-name', 'ctrl+f6')
// or
this.$shortcut.add('commandName', ['ctrl', 'f6'])

Remove existing keybinding

this.$shortcut.remove('command-name', 'ctrl+f6')
// unbind all actions for this shortcut
this.$shortcut.unbind(['ctrl', 'f6'])
// clear all keybindings
this.$shortcut.clear()

Derived from

  • Vivify-Ideas/vue-shortcuts
  • MetinSeylan/Vue-Socket.io
  • mazinsw/vue-keybindings

Keywords

shortcut

FAQs

Package last updated on 30 Aug 2023

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.