Return true if key is down in javascript loop?
<p>I want to add a condition inside a loop that tests if the right arrow is pressed and if it is move a div a bit to the right. However I don't know how to check for they keydown. </p>

<p>I'm using a code to do it but it is really long and I'm sure there is an shorter way to do it.</p>

<p>This is the code:</p>

<pre><code>    &lt;div id="char"&gt;&lt;/div&gt;
    &lt;script&gt;
    setInterval(function() {

// here it should check if RIGHT (keycode 39) is down and move char 10px to the right if it is;

    }, 20);
    &lt;/script&gt;
</code></pre>

<p>How can I check for keydown inside the loop? Btw I'm also using jQuery on the site.</p>

<p>Thanks</p>
