← Back to context

Comment by kyle_t

11 years ago

I was surprised at how well that worked. I was basically blindly cycling between left,down,right (with one accidental up) and got to 1024 on my first try.

function press(key) { var eventObj = document.createEvent("Events"); eventObj.initEvent("keydown", true, true); eventObj.which = key; document.dispatchEvent(eventObj); }

for (y=0; y<=1000; y++) { press(39); //right press(40); //down press(37); //left press(40); //down }

this gave me 1024 in couple of tries :D http://i58.tinypic.com/am9sh4.png

  • Here's a random key press loop: function press(key) { var eventObj = document.createEvent("Events"); eventObj.initEvent("keydown", true, true); eventObj.which = key; document.dispatchEvent(eventObj); } for (y=0; y<=1000; y++) { press(Math.floor(Math.random() * 4) + 37); }