![禁用 github 焦点搜索栏快捷方式](https://linux22.com/image/1613708/%E7%A6%81%E7%94%A8%20github%20%E7%84%A6%E7%82%B9%E6%90%9C%E7%B4%A2%E6%A0%8F%E5%BF%AB%E6%8D%B7%E6%96%B9%E5%BC%8F.png)
正如所描述的Github - 键盘快捷键,s是聚焦搜索栏的快捷方式。可以禁用该功能吗?
答案1
经过修改这评论
安装 Grease Monkey (FF) 并使用此脚本
// Your code here...
// ==UserScript==
// @name Disable keyboard shortcuts
// @description Stop websites from highjacking keyboard shortcuts
//
// @run-at document-start
// @include *github.com*
// @grant none
// ==/UserScript==
keycodes = [83] // Keycode for 'S', add more keycodes to disable other key captures
document.addEventListener('keydown', function(e) {
// alert(e.keyCode); //uncomment to find out the keycode for any given key
if (keycodes.indexOf(e.keyCode) != -1)
{
e.cancelBubble = true;
e.stopImmediatePropagation();
}
return false;
});
或者下载 TamperMonkey(Chrome)并使用此脚本
// Your code here...
// ==UserScript==
// @name Disable keyboard shortcuts
// @description Stop websites from highjacking keyboard shortcuts
//
// @run-at document-start
// @include *github.com*
// @grant none
// ==/UserScript==
document.addEventListener('keydown', function(e) {
if (e.keyCode == 83) {
e.cancelBubble = true;
e.stopImmediatePropagation();
}
return false;
});