 |
 |
 |
 |
Name |
|
keyCode |
 |
|
|
Examples |
|
color fillVal = color(126);
void draw() {
fill(fillVal);
rect(25, 25, 50, 50);
}
void keyPressed() {
if(key == CODED) {
if (keyCode == UP) {
fillVal = 255;
} else if (keyCode == DOWN) {
fillVal = 0;
}
} else {
fillVal = 126;
}
}
|
|
|
Description |
|
The system variable keyCode is used to detect special keys such as the UP, DOWN, LEFT, or RIGHT keys on the keyboard. Other special key constants are ALT, CONTROL, SHIFT, BACKSPACE, TAB, ENTER, RETURN, ESC, and DELETE. Before testin which coded key is pressed it's necessary to test and see if the key is coded at all. This is done with the conditional "if(key == CODED) {}" as shown in the above example. |
 |
|
|
Syntax |
|
keyCode
|
 |
|
|
Usage |
|
Web & Application |
 |
|
|
Related |
|
key keyPressed keyPressed() keyReleased() |
|
|