title: onkeydown event not working on canvas?
body: <p>I've got a canvas and an <code>onkeydown</code> event assigned to it. When <strong>any</strong> key is pressed, the console is supposed to log the keyCode of the key. But it's not outputting anything, not even <code>undefined</code>. Other handlers like <code>onclick</code> are working fine, but <code>onkeydown</code> is not. I've also tried using <code>onkeypress</code> and <code>onkeyup</code>, but these don't work either. Here's the full code: </p>
  
  <pre><code>canvas.onkeydown = function(e){
      if(e.keyCode === 37){
          ctx.clearRect(0,0,canvas.width,canvas.height);
          ctx.drawImage(knife,knifeX - 10, knifeY);
          knifeX -= 10;
      }
      else if(e.keyCode === 39){
          ctx.clearRect(0,0,canvas.width,canvas.height);
          ctx.drawImage(knife,knifeX + 10, knifeY);
          knifeX += 10;           
      }
      else if(e.keyCode === 38){
          ctx.clearRect(0,0,canvas.width,canvas.height);
          ctx.drawImage(knife,knifeX, knifeY + 10);
          knifeY += 10;
      }
      else if(e.keyCode === 40){
          ctx.clearRect(0,0,canvas.width,canvas.height);
          ctx.drawImage(knife,knifeX, knifeY - 10);
          knifeY -= 10;               
      }
      console.log(e.keyCode);     
  }
  </code></pre>