gabrielecirulli/2048 — pull request #152 by giodamelio (2014-04-14 03:19:45+00:00)
Title: Listen for javascript events to allow easier automation.

A simple interface to allow commands to be sent to the game via javascript events.

**Story:** I was trying to make a userscript that would automate 2048. There didn't seem to be any easy way to control the game short of sending keystrokes(cross-browser support is a pain), so I added this.

To send an event, simple run this code from a script on the same page(userscript/bookmarklet)

```javascript
// You can send "up"/"right"/"down"/"left"
var event = new CustomEvent("move", { "detail": { "direction": "right"} })
document.dispatchEvent(event);
```