Skip to content

Instantly share code, notes, and snippets.

@bernatfortet
Created March 11, 2014 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bernatfortet/9490875 to your computer and use it in GitHub Desktop.
Save bernatfortet/9490875 to your computer and use it in GitHub Desktop.
function pressUp(){
pressKey('up');
}
function pressRight(){
pressKey('right');
}
function pressDown(){
pressKey('down');
}
function pressLeft(){
pressKey('left');
}
function pressLeft(){
pressKey('space');
}
function pressKey(key){
var e = jQuery.Event("keydown");
switch( key ){
case 'up':
e.which = 38;
break;
case 'right':
e.which = 39;
break;
case 'down':
e.which = 40;
break;
case 'left':
e.which = 37;
break;
case 'space':
e.which = 32;
break;
}
e.keyCode = e.which;
$("body").trigger(e);
}
function anaylize(){
setTimeout( function(){
pressDown();
anaylize();
}, 200 )
}
anaylize();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment