respond to key press javascript
<p>I'm sorry if this is basic, but I've searched and found nothing that works.  </p>

<p>I want to load a web page.  When that page loads, it displays an image.  I want to have the page automatically start listening for a right arrow key press.  When that happens, a function in my script will change the image (that part I have gotten to work by using a button that reacts when clicked).</p>

<p>It's the listening for and reacting to a key press I cannot get to work.  Note that I'm using Safari, but I would like if possible for it to work in firefox or IE as well.</p>

<p>Please help thanks.</p>

<p>UPDATE TO RESPOND TO COMMENT:  Here is what I tried, though I simplified the other part to make this shorter -- now it just writes a result to a div:</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script language="Javascript"&gt;
function reactKey(evt) {
   if(evt.keyCode==40) {
      document.getElementById('output').innerHTML='it worked';
   }
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onLoad="document.onkeypress = reactKey();"&gt;
&lt;div id="output"&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
