Skip to content

Instantly share code, notes, and snippets.

@NigoroJr
Created October 2, 2016 23:33
Show Gist options
  • Save NigoroJr/a2fcdca42255c8d6a2bdf002a554d457 to your computer and use it in GitHub Desktop.
Save NigoroJr/a2fcdca42255c8d6a2bdf002a554d457 to your computer and use it in GitHub Desktop.
// ==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