title: Simple movement in javascript
body: <p>I am making a game in JavaScript, and I am wondering how I can make objects move smoothly when you press the left and right key. So far, I've gotten a circle to move left and right. If you hold the right arrow key, the circle moves to the right, however, if you then press the left key at the same time it kind of glitches and stops moving, and vice versa. I want it so that when I press the right arrow key, and while still pressing it, I press the left key, the circle will go left, and vice versa. Anyhow, here is my code:</p>
  
  <pre><code>var x = 200;
  draw = function() {
      background(255,255,255);
      ellipse(x, 200, 50, 50);
      if (keyIsPressed &amp;&amp; keyCode === RIGHT){ //if right key pressed
              x += 5;
          }
          if (keyIsPressed &amp;&amp; keyCode === LEFT){ //if left key pressed
              x -= 5;
          }
  };
  </code></pre>