The gameplay gif you can see on https://github.com/epidemian/snake is a lie. It was not played by a person, but recorded move-by-move.
The code on record-moves.js was used to first record "player" moves one by one and then the code on replay-moves.js was used to replay them on the game.
The readme-moves.json file contains the moves used on the README.
To record the gif, byzanz-record
was used, which is the only tool I found that could generate good quality gifs with good-enough frame rate.