how to disable github hotkeys/keyboard shortcuts
阿新 • • 發佈:2019-01-02
Tampermonkey
, The chrome app, is able to achieve this. The script is as following.
// ==UserScript==
// @name Disable keyboard shortcuts at github
// @description Stop websites from highjacking keyboard shortcuts
//
// @run-at document-start
// @include *github.com*
// @grant none
// Disable keyboard shortcuts on GitHub? - Web Applications Stack Exchange
// https://webapps.stackexchange.com/questions/51256/disable-keyboard-shortcuts-on-github
// where to find keycodes
// JavaScript Event KeyCodes
// http://keycode.info/
// ==/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;
});
step by step
create a new script
paste the script
The previous scrip just disable the key s
.
save the script
After saving the script and refreshing the github page, the keyboard shortcut s
in github is disabled.