Unexpected token void - keyReleased / keyPressed

edited May 2017 in Questions about Code

Hey, I was just trying some stuff around with processing and ended up with a problem i cant find out why happens. The problem is that i get "Unexpected token void" on keyReleased in this simple code:

  boolean[] keys = new boolean[2];
  String hallo;
  int x = 40;
  int y = 40;

  void setup() {
    size(1200, 700); 
    textSize(20);
    background(0);
    keys[0] = false;
    keys[1] = false;
 }

  void draw() {

    if (keys[0]){
      hallo = "a";
      text(hallo, x, y);
      x += 10;
    }

    void keyPressed() { 
      if (key == 'a')
        keys[0] = true; 
      }

    void keyReleased() {  
      if (key == 'a')
        keys[0] = false;
      }
    }
Tagged:

Answers

  • Answer ✓

    if you use ctrl-t in the editor it'll indent your code nicely and can help you spot errors.

    where does your draw() finish?

Sign In or Register to comment.