Created
May 2, 2016 22:07
-
-
Save ccondry/327ca0947848c7a4326f1803d9fa6622 to your computer and use it in GitHub Desktop.
Detect keypress for keyboard combination CTRL + any key.
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
/* | |
Originally from http://www.gmarwaha.com/blog/2009/06/16/ctrl-key-combination-simple-jquery-plugin/ | |
*/ | |
$.ctrl = function(key, callback, args) { | |
$(document).keydown(function(e) { | |
if(!args) args=[]; // IE barks when args is null | |
if(e.keyCode == key.charCodeAt(0) && e.ctrlKey) { | |
callback.apply(this, args); | |
return false; | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment