Last active
December 16, 2015 19:59
-
-
Save ryo1kato/5489419 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 DontStealMyShurtcut | |
| // @namespace http://ryo1kato.github.com/ | |
| // @version 0.1 | |
| // @description enter something useful | |
| // @match https://docs.google.com/spreadsheet/* | |
| // @require http://code.jquery.com/jquery-latest.min.js | |
| // ==/UserScript== | |
| function disableCtrlKeyCombination(e) | |
| { | |
| //list all CTRL + key combinations you want to disable | |
| var forbiddenKeys = new Array('a', 'e', 'n', 'p', 'f', 'b', 'd'); | |
| var key; | |
| var isCtrl; | |
| if(window.event) | |
| { | |
| key = window.event.keyCode; //IE | |
| if(window.event.ctrlKey) | |
| isCtrl = true; | |
| else | |
| isCtrl = false; | |
| } | |
| else | |
| { | |
| key = e.which; //firefox | |
| if(e.ctrlKey) | |
| isCtrl = true; | |
| else | |
| isCtrl = false; | |
| } | |
| //if ctrl is pressed check if other key is in forbidenKeys array | |
| if(isCtrl) | |
| { | |
| for(i=0; i<forbiddenkeys .length; i++) | |
| { | |
| //case-insensitive comparation | |
| if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase()) | |
| { | |
| e.stopPropagation(); | |
| return true; | |
| } | |
| } | |
| } | |
| return true; | |
| } | |
| $("div.cell-input").on('keydown', function(e){ disableCtrlKeyCombination(e) } ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment