Created
July 31, 2009 01:21
-
-
Save jamescarr/159033 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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