how to disable github hotkeys/keyboard shortcuts

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.

ref

Disable keyboard shortcuts on GitHub? - Web Applications Stack Exchange
https://webapps.stackexchange.com/questions/51256/disable-keyboard-shortcuts-on-github

JavaScript Event KeyCodes
http://keycode.info/

posted on 2018-08-21 12:20  yusisc  阅读(35)  评论(0编辑  收藏  举报

导航