@4rk/vue-mousetrap

2.0.2 • Public • Published

@4rk/vue-mousetrap

A Vue plugin providing a directive to add global keyboard shortcuts to your components based on Mousetrap.

Installation

import VueMousetrap from "@4rk/vue-mousetrap";

Vue.use(VueMousetrap);

Usage

<template>
  <div v-mousetrap="['mod+s']" @mousetrap="onMousetrap">
    hit ctrl-s to save
  </div>
</template>

<script>
export default {
  methods: {
    onMousetrap() {
      console.log("save!");
    }
  }
};
</script>

API

The v-mousetrap directive expects a Moustrap compatible value as defined at Mousetrap.bind.

The @mousetrap event triggers with the Mousetrap event.

Package Sidebar

Install

npm i @4rk/vue-mousetrap

Weekly Downloads

3

Version

2.0.2

License

MIT

Unpacked Size

5.11 MB

Total Files

7

Last publish

Collaborators

  • jonas.leonhard
  • barnslig
  • holmey