0.1.2 • Published 4 years ago

vue-hot-key v0.1.2

Weekly downloads
10
License
MIT
Repository
github
Last release
4 years ago

vue-hot-key


vue-hot-key 是一款基于vue2+的快捷键自定义指令

安装

npm install --save vue-hot-key

使用

<template>
  <div id="app" v-hotkey="hotKeyMap">
    请尝试同时按下 alt+s 键 <br><br>
    请尝试同时按下 ctrl+x 键 <br><br>
    请尝试同时按下 ctrl+c 键 <br><br>
    请尝试同时按下 ctrl+v 键 <br><br>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'

@Component
export default class App extends Vue {
  get hotKeyMap () {
    return {
      'alt+s': this.save,
      'ctrl+x': this.ctrlX,
      'ctrl+c': this.ctrlC,
      'ctrl+v': this.ctrlV
    }
  }

  save () {
    alert('alt+s')
  }

  ctrlX () {
    alert('ctrl+x')
  }

  ctrlC () {
    alert('ctrl+c')
  }

  ctrlV () {
    alert('ctrl+v')
  }
}
</script>