Skip to content

Instantly share code, notes, and snippets.

@azu
Created August 1, 2017 00:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azu/06e4ed6077d79b07827646716c902517 to your computer and use it in GitHub Desktop.
Save azu/06e4ed6077d79b07827646716c902517 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Disable keyboard shortcuts
// @description Stop websites from highjacking keyboard shortcuts
//
// @run-at document-start
// @include https://github.com/*
// @grant none
// ==/UserScript==
keycodes = [84] // Keycode for 'T', 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;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment