Skip to content

Instantly share code, notes, and snippets.

@mamacdon
Created August 13, 2014 03:00
Show Gist options
  • Save mamacdon/ac192ba0692d27fb2527 to your computer and use it in GitHub Desktop.
Save mamacdon/ac192ba0692d27fb2527 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 *
// @grant none
// ==/UserScript==
keycodes = [191] // Keycode for '/', 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