see title
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A simple way to add key handling to jquery

To start just add 

Then you can do fancy stuff like:

$.whenPressed('j',function(){ alert('you pressed j');});

$('h1').whenPressed('h',function(){ $(this).hide();});

if you pass it a string it will look through its dictionary for the keycode. If passed an integer, it will assume thats the keycode and use that

I also added some helper methods:


will set the pages location to anchor's href.

there's also tests for the keycode

$.isLetter(keyCode) will check to see if the key code is a letter

$.isNumber(keyCode) will check to see if the key is a number, including the numpad

$('div').scrollTo() will scroll to fit the element in the window if its outside the viewable area

$('div').find('h1').or('p') will return h1 if it exists, if not it will look for p 

You can also suspend watching the keys (it does automatically when you enter an input field) with


then start again


Oh and this is a product of Downtown Cartel ( and is in use(or will be soon) on