Created
March 11, 2014 17:36
-
-
Save bernatfortet/9490875 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 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