FAQ
 
 
Cover  \ Exhibition  \ Learning  \ Reference  \ Download  \ Discourse   
      Language \ Environment \ Libraries \ Comparison
 
   
   
Abridged (A-Z) \ Complete (A-Z)  
   
  Reference for Processing (BETA) version 91+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.  
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()
 
 






   
 
Updated: Fri Jul 15 16:35:42 PDT 2005
 
 








Creative Commons License
 
  Processing is an open project initiated by Ben Fry and Casey Reas  
  © Info