title: How to fix delay in javascript keydown
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11197220/javascript-move-delay-and-multiple-keystrokes">JavaScript move delay and multiple keystrokes</a>  </p>
  </blockquote>
  
  
  
  <p>I'm new and learning HTML5 canvas together with javascript. I've created an event to move an object left and right, and my problem is the delay whenever you hold the key or switch to another key. I know there's missing on my code below please help me. Thank you in advance.</p>
  
  <pre><code>c.addEventListener('keydown',this.check,true);
    function check(el) {
      var code = el.keyCode || el.which;
      if (code == 37 || code == 65){
      x -=1;
      }
  
      if (code == 39 || code == 68){
      x += 1;
      }
  
    el.preventDefault();
  }
  </code></pre>