javascript监听按键

document.addEventListener('keydown',test);
function test(e){
      var x=e.keyCode;
      if(x == 49){
         console.log("hello");
      }
}
posted @ 2018-07-13 10:45  sherlock-merlin  阅读(645)  评论(0编辑  收藏  举报