Created
October 2, 2016 23:33
-
-
Save NigoroJr/a2fcdca42255c8d6a2bdf002a554d457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Disable Ctrl | |
// @description Stops websites from stealing Ctrl keys | |
// @run-at document-start | |
// @include * | |
// @match https://*/* | |
// @match http://*/* | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; | |
var func = function(e) { | |
//console.log(e.keyCode); | |
// C-d, C-h, and C-l (u == 85) | |
var ignore = [68, 72, 76]; | |
if ((e.ctrlKey || e.metaKey) && ignore.indexOf(e.keyCode) == -1) { | |
e.cancelBubble = true; | |
e.stopPropagation(); | |
e.stopImmediatePropagation(); | |
//console.log('Captured!'); | |
} | |
return false; | |
}; | |
(window.opera ? document.body : document).addEventListener('keypress', func, !window.opera); | |
(window.opera ? document.body : document).addEventListener('keydown', func, !window.opera); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment