title: Implementing @keypress in Vue
body: <p>I am trying to implement <code>onkeypress</code> event in a Vue component. On keypress I want to restrict all key codes except numbers. I am trying the following.</p>
  <p>Using the onkeypress event, things work fine!</p>
  <pre><code>&lt;input type=&quot;number&quot; onkeypress=&quot;return (event.charCode === 0 || /\d/.test(String.fromCharCode(event.charCode)));&quot; /&gt;
  </code></pre>
  <p>When I convert the above to be used in Vue, it does not work!!! :(</p>
  <pre><code>&lt;input type=&quot;number&quot; @keypress=&quot;restrictChars($event)&quot; /&gt;
  
  &lt;script&gt;
      export default {
      name: 'quantity-selector',
      methods: {
          restrictChars: function($event) {
              return ($event.charCode === 0 || /\d/.test(String.fromCharCode($event.charCode)));
          }
      }
  </code></pre>
  <p>What am I missing?? I don't understand what is going wrong? Any help is hugely appreciated!</p>