title: How can I capture keyboard events are from which keys?
body: <p>I googled and got the following codes on the Net.However, when I press a keyboard key,it is not displaying me an alert box. I want to get which character I have pressed in the alert box. How do I fix this?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  var charfield=document.getElementById("char")
  charfield.onkeydown=function(e){
  var e=window.event || e;
  alert(e.keyCode);
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body id="char"&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>