Return to Snippet

Revision: 25384
at March 29, 2010 14:44 by adamcoulombe


Initial Code
(function($){
 $.fn.extend({
 
 	onKeyboardSmashed : function(callbackFunction,options) {
		var defaults = {
			threshold: 3
		};
		
	  var options = $.extend(defaults, options);
	  
	  
	  return this.each(function() {

			var keys_pressed = 0 ;
			$(this).keydown(function(event) {
				keys_pressed++
			
					if( keys_pressed >options.threshold){
						    if(typeof callbackFunction == 'function'){
							  callbackFunction.call(this);
							}
					}
			});
			
			$(this).keyup(function(event) {
				keys_pressed--;
			});
		
	  });
	  
	}
 });
})(jQuery);

Initial URL
http://adamcoulombe.info/lab/jquery/onkeyboardsmashed/

Initial Description
This jQuery plugin can be used to detect when the user smashes their keyboard.

You can set a threshold as to how many keys need to be depressed in order to trigger the event.

Initial Title
jQuery onKeyboardSmashed event Plugin

Initial Tags
event, jquery

Initial Language
jQuery