Thanks for this. It's a lot better than my attempts with GameMaker and PyGame. GameMaker has a nasty lag problem with keyboard events that ruins games like this.
Develop games in your browser. Powerful, performant & highly capable.