JavaScript execute until keypress
<p>I want to execute a loop/action until a key is pressed and onpress I want to stop that action and call the function <code>getKey</code>. Can anybody suggest how to do this?</p>

<pre><code>function getKey(e) 
{
    var pressedKey;
    if (document.all)   { e = window.event; }
    if (document.layers || e.which) { pressedKey = e.which; }
    pressedCharacter = String.fromCharCode(pressedKey).toLowerCase();
    move(pressedCharacter);

}

document.onkeypress = getKey;
</code></pre>

<p>I want the move() function to be executing continuously till a key is not pressed . if it's pressed i want to re-execute the move() function with the new pressed character  </p>
