title: Detecting keyboard button and play sound in vue.js
body: <p>The code below actually plays sounds on each button click with vue.js.</p>
  <p>How is it possible to detect keyboard press and play sound when DOM is ready and not when the buttons are clicked?</p>
  <p>for example on enter play sound <code>v-on:keyup.13=&quot;playSound('path/to/mp3')&quot;</code></p>
  <p>Vue documentation mostly explains html attributes, perhaps this is something that needs to be done in JS, i guess. I am new to Vue.js</p>
  <p>Vue.js documentation on <a href="https://v2.vuejs.org/v2/guide/events.html#Key-Modifiers" rel="nofollow noreferrer">Event Modifiers</a></p>
  <p>See the <a href="https://codepen.io/anon/pen/errzdK" rel="nofollow noreferrer">codepen</a>.</p>
  <pre><code>new Vue({
    el: '#app',
    data: {
      text: ''
    },
    methods: {
      playSound (sound) {
        if(sound) {
          var audio = new Audio(sound);
          audio.play();
        }
      }
    }
  });
  </code></pre>