Created
March 12, 2014 02:53
-
-
Save juanplopes/9499924 to your computer and use it in GitHub Desktop.
Este script provavelmente joga 2048 melhor que você
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
var sendSingle = function(key) { | |
var event = new KeyboardEvent('keydown'); | |
Object.defineProperty(event, 'keyCode', {get : function() {return key;}}); | |
Object.defineProperty(event, 'which', {get : function() {return key;}}); | |
document.dispatchEvent(event); | |
} | |
var i = 0; | |
handle = setInterval(function() { | |
console.log(i); | |
if (i == 0) | |
sendSingle(37); | |
if (i == 1) | |
sendSingle(40); | |
if (i == 2) | |
sendSingle(39); | |
if (i == 3) | |
sendSingle(40); | |
i = (i+1)%4; | |
}, 50); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment