Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
5 lines (4 sloc) 690 Bytes
/* jQuery Shortcuts http://github.com/ambethia/jquery-shortcuts */
jQuery.fn.shortcuts=function(keys){var self=this;this.pressed=new Array();jQuery(this).keydown(function(event){if(this!==event.target&&(/textarea|select/i.test(event.target.nodeName)||event.target.type==="text")){return;}
self.pressed.push(event.keyCode);for(combo in keys){if(self.compare(keys[combo].keys,self.pressed)){keys[combo].func(event);};};});jQuery(this).keyup(function(event){self.pressed.splice(jQuery.inArray(event.keyCode,self.pressed),1);});this.compare=function(a,b){if(a.length!=b.length)return false;a.sort();b.sort();for(var i=0;i<a.length;i++){if(a[i]!=b[i])return false;};return true;}
return this;};