Moving Shapes on the Canvas Using the Keyboard

On the canvas, one of the most common things you’ll do with the keyboard is use the arrow keys to move something around. For example, click on the following triangle and click on any of your arrow keys:

Notice that the triangle moves in the direction of whichever arrow key you pressed.

In this tutorial, you will learn how to create this example. You will learn all about how to listen for key presses and move something around the screen as a reaction to whichever key was pressed. Of course, since nothing is ever as straightforward as it seems, we'll touch upon a bunch of other relevant topics along the way :P

Onwards!