禁止某些键盘事件

document.addEventListener('keydown', function(event){    
  return !(

    112 == event.keyCode || //F1

    123 == event.keyCode || //F12

    event.ctrlKey && 82 == event.keyCode || //ctrl + R

    event.ctrlKey && 78 == event.keyCode || //ctrl + N

    event.shiftKey && 121 == event.keyCode || //shift + F10

    event.altKey && 115 == event.keyCode || //alt + F4

    "A" == event.srcElement.tagName && event.shiftKey //shift + 点击a标签

  ) || (event.returnValue = false)
}
);
posted @ 2020-01-19 15:56  入坑的H  阅读(266)  评论(0编辑  收藏  举报