Code skill Controlling the Snake

This piece of code will add input handling so that the player can use the keyboard to control the snake. You will use the eventListener method to record which key is pressed and the processInput function to tell the snake in which direction to move. You will also use clearTimeout to stop the snake from speeding up.

You may need to click in the Result box to move the snake on this screen.


See the Pen GB6 M2 by Walker Books UK (@walkerbooks) on CodePen.