title: How to disable repetitive keydown in JavaScript
body: <p>I have a same problem like this guy <a href="https://stackoverflow.com/questions/9098901/how-to-disable-repetitive-keydown-in-jquery">How to disable repetitive keydown in jQuery</a> , it's just that I'm not using jQuery so I'm having hard time translating it to "pure" JavaScript, anyways I have set <code>switch</code>-case of some keys and when I press and hold right arrow key my div is flying. Also if it's not a problem can you tell me what would be the easiest way to stop div movement when I let the right arrow key go, do I have to make a new switch case with <code>clearInterval</code> or?</p>
  
  <pre><code>switch (keyPressed) {
      case 39:
          setInterval(movFwr, 50);
          break;
  }
  
  function movFwr() {
      if (currPos == 1000) {
          a.style.left = 1000 + "px";
      } else currPos += 10;
      a.style.left = trenutnaPozicija + "px";
  }
  </code></pre>
  
  <p>I'm sorry guys, I've been busy a bit, I'm testing all possibilities and so far I have seen some interesting suggestions. I'll test em all these days and then rate of what ever is that you do on this site. Great community I must say. Thank you all for your help :) </p>