• The keyPressed() function is called once every time a key is pressed. The key that was pressed is stored in the key variable.
  • The keyReleased() function is called once every time a key is released. The key that was released will be stored in the key variable
  • The keyTyped() function is called once every time a key is pressed, but action keys such as Ctrl, Shift, and Alt are ignored.
  • keyCode stores the special key values (space, enter, up down etc) when key is CODED
  • Try the follwing one at a time.
  • void setup(){
      size(500,375);
      background(255);
      smooth();
    }
    void draw(){
      PFont font;
      fill(0);
      font = loadFont("CenturySchL-Roma-48.vlw"); 
      textFont(font); 
    }
    
    //case 1
    void keyPressed() { 
    text("pressed ="+key, 15, 100);   
    }
    
    //case 2	
    void keyReleased() { 
      text("released "+key, 15, 200);
    }
    
    //case 3	
    void keyTyped() { 
     println("released " + int(key) + " " + keyCode);
    }