js键盘事件,按ctrl+t会打开新tab,如何禁止

新手上路,请多包涵

如题。。我需要写一个键盘事件,ctrl+t,但是目前组合键会打开一个新页面,不执行我的js方法,请问,如何解决### 题目描述

if (oEvent.keyCode == 84 && oEvent.ctrlKey) {

emit.$emit('keyAlign','ico4')
/*延迟,兼容FF浏览器  */
  setTimeout( () =>{
  },1);
return false;

}

阅读 3.5k
3 个回答
In Chrome4, certain control key combinations have been reserved for browser usage only and can no longer be intercepted by the client side JavaScript in the web page.
These restrictions did not exist in Chrome3 and are inconsistent with both Firefox3/3.5 and IE7/8 (on Windows).

These combinations cannot get captured by Javascript, but embed plugins can capture these. For example if you focus in a Youtube video and press Ctrl+T, the browser won't open a new tab.

javascript-capture-browser-shortcuts-ctrlt-n-w

系统级别的操作还是不要去折腾了,你总不能禁止ctrl+c去复制吧

什么浏览器?有些浏览器,比如chrome是拦截不到ctrl+t的。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题