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  

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
   
Usage   Web & Application
   
Related   keyPressed
keyCode
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