HTML5画布上用于keydown的addEventListener
使用的TabIndex 为的addEventListener画布canvas元素的属性-
var myTarget, myCanvas; window.onload = function() { myCanvas = document.getElementById('canvas'); document.addEventListener('mousedown', function(event) { myTarget = event.target; alert('This is mousedown event.'); }, false); document.addEventListener('keydown', function(event) { if(myTarget == myCanvas) { alert('This is keydown event.'); } }, false); }