JSFiddle - React, Tailwind, and code Playground

by Hristiyan Dodov

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.6/vue.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/index.js"></script>
<div id="app"></div>

JavaScript

Vue.use(VueShortkey)

new Vue({
	el: '#app',
  data () {
		return {
    	altPressed: false
    }
	},
  template: `
  	<h1
    	v-shortkey.push="['alt']"
      @shortkey="handleShortkey"
    >
    	alt: {{ altPressed }}
    </h1>
  `,
  methods: {
  	handleShortkey (event) {
    	this.altPressed = !this.altPressed
    	console.log(event)
    }
  }
})