a port of the Processing Visualization Language
Name

key

Examples
// Click on the window to give it focus

// and press the 'B' key



void draw() {

  if(keyPressed) {

    if (key == 'b' || key == 'B') {

      fill(0);

    }

  } else {

    fill(255);

  }

  rect(25, 25, 50, 50);

}
Description The system variable key always contains the value of the most recently pressed key on the keyboard. For detecting the arrow keys, the keyCode variable is set to either UP, DOWN, LEFT, or RIGHT.
Syntax
key
Parameters
Usage Web & Application
Related keyCode
keyPressed
keyPressed()
keyReleased()

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub