jQuery Keyboard Input

I was working on some jQuery today in a WordPress theme I’m working on, and I wanted to simulate a keyboard input so that I could force a jQuery plugin to work in the way I wanted it to without hacking its core.  Here’s how you do it:


  1. First figure out the e.which code for what key you want to ‘fake’ being pushed using this tool.
  2. Then create the jQuery (in your document ready or wherever you are going to use it) to simulate the keydown event
    	//create event var
    	e = jQuery.Event("keydown");
    	//set which key is being pressed
    	e.which = 40 ;
    	//trigger the event

Beautiful isn’t it 🙂

1 thought on “jQuery Keyboard Input

  1. wow dude thats like super simple!! thanks will give it a try!!!

Leave a Reply

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close