Skip to content

Instantly share code, notes, and snippets.

@jamescarr
Created July 31, 2009 01:21
Show Gist options
  • Save jamescarr/159033 to your computer and use it in GitHub Desktop.
Save jamescarr/159033 to your computer and use it in GitHub Desktop.
function TestUser(){
this.keyMap = {A:65, B:66, ENTER:14, LEFT:37, UP:38, RIGHT:39, DOWN:40};
}
TestUser.prototype.pressesKey = function(key){
var e = jQuery.Event("keypress");
e.keyCode = this.keyMap[key.toUpperCase()];
$().trigger(e)
}
// -- using it
var user = new TestUser();
user.pressesKey('up');
user.pressesKey('left');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment