title: Ignoring input characters on key down
body: <p>I want to ignore certain characters in my phone input, so that the database just has digits. I know I can do this easy on server side (using PHP) but I am trying to understand js events a little better.. My question is this:</p>
  
  <p>If I have a basic input:</p>
  
  <pre><code>var phoneInput = document.getElementById("phoneInput");
  </code></pre>
  
  <p>I can add an event listener using "onkeydown" which works fine</p>
  
  <pre><code>phoneInput.onkeydown = function(e){
    var c = String.fromCharCode(e.keyCode);
    var patt = /\d/;
    if(!patt.test(c)) return false;
  };
  </code></pre>
  
  <p>But if I try doing the same thing using 'addEventListener', returning false seems to do nothing</p>
  
  <pre><code>phoneInput.addEventListener("keydown",function(e){
    var c = String.fromCharCode(e.keyCode);
    var patt = /\d/;
    if(!patt.test(c)) return false;
  });
  </code></pre>
  
  <p>I just don't understand why. Thanks in advance for any light you can shine on the subject..</p>