javascript监听按键

document.addEventListener('keydown',test);
function test(e){
      var x=e.keyCode;
      if(x == 49){
         console.log("hello");
      }
}
原文地址:https://www.cnblogs.com/sherlock-merlin/p/9303703.html