This code is run every time the computer detects a key press. A variable "keyCode" holds the numerical value that represents the specific key that was pressed. For example, if I press the UP arrow, keyCode will be a 38. void keyPressed(){ print(keyCode + " "); //This gives you the key code number for any key you press during your program if(keyCode == 38){ //38 is the key code for UP speedy = -2; }else if(keyCode == 40){ //This is for down speedy = 2; } //Keep adding else if's to get all the keys you need for your program }