Home‎ > ‎Unit 04‎ > ‎

Keyboard Input

No video for this lesson. The ideas here are really the same as for mousePressed. Read through the remainder of Chapter 5 and try out all the examples. Below are the high points.

Like mousePressed, keyPressed can be true or false. If true the state of key is changed to match the key that was pressed. This is case sensitive and can be used with letters, numbers, and symbols only. The key variable will store the value of the last key pressed until a new key is pressed.

If you use one of the special keys, such as an arrow key, then CODED is stored in key. The specific special key is stored in keyCode.

Assignment 4.6 - Change your robot code to respond to the arrow keys on your keyboard.
Comments