Skip to content

Instantly share code, notes, and snippets.

@ryo1kato
Last active December 16, 2015 19:59
Show Gist options
  • Select an option

  • Save ryo1kato/5489419 to your computer and use it in GitHub Desktop.

Select an option

Save ryo1kato/5489419 to your computer and use it in GitHub Desktop.
// ==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