Q:

Key Pressed Experiment: unexpected token: void Processing 2.2.1

So I've been picking apart a friend's pong game in order to figure out keyPressed functions, and use them in my balloon game that I mentioned in another post. I believe I've put the code together correctly, keeping procedure and the logical order of things in mind, but for some reason the unexpected token:void keeps coming up as an error message. I've closed off all brackets, and declared all of the global variables to the best of my knowledge, but I keep running into this message.
Here's the code:
int level;

int paddleWidth = 200;
int paddleHeight = 200;
int paddleSpeed = 5;

int posX;
int posY;

boolean p1UP = false;
boolean p1DOWN = false;
boolean p1LEFT = false;
boolean p1RIGHT = false;

void setup()  {

size (800,800);
frameRate(60);
smooth();

posX = width/2;
posY = height/2;

}

void draw()  {

if (level==0) {
background(0);
textSize(50);
text("PREPARE YOUR ANUS", width/2, height/2-200);
text("PRESS A KEY YOU DINGUS", width/2, height/2-400);
if (keyPressed) level=1;

}

if (level==1) {
background(0);

fill(posX,0,posY);
rect(posX, posY, paddeWidth, paddleHeight);

if(p1UP==true) {
  posY -=paddleSpeed;
}
if(p1DOWN==true) {
  posY +=paddleSpeed;
}
if(p1LEFT==true) {
  posX -= paddleSpeed;
}
 if(p1RIGHT==true) {
  posX += paddleSpeed;
}

void keyPressed()  {

if (key=='w' || key=='W') {
p1UP = true;
}
if (key=='s' || key=='S') {
p1DOWN = true;
}  
if (key=='a' || key=='A') {
p1LEFT = true;
}
if (key=='d' || key=='D') {
p1RIGHT = true;
}
} 

void keyReleased()  {

if (key=='w' || key=='W') {
p1UP = false;
}
if (key=='s' || key=='S') {
p1DOWN = false;
}  
if (key=='a' || key=='A') {
p1LEFT = false;
}
if (key=='d' || key=='D') {
p1RIGHT = false;
}
} 

}
}

A:

Please use proper formatting. Your indentation made this really hard to read, which is probably why you didn't get an answer right away.
The code with proper formatting looks like this:
boolean p1UP = false;
boolean p1DOWN = false;
boolean p1LEFT = false;
boolean p1RIGHT = false;

void setup()  {
   size (800,800);
   frameRate(60);
   smooth();
   posX = width/2;
   posY = height/2;
}

void draw()  {
   if (level==0) {
      background(0);
      textSize(50);
      text("use more mature examples", width/2, height/2-200);
      text("PRESS A KEY please", width/2, height/2-400);

      if (keyPressed) level=1;

   }

   if (level==1) {
      background(0);

      fill(posX,0,posY);
      rect(posX, posY, paddeWidth, paddleHeight);

      if(p1UP==true) {
         posY -=paddleSpeed;
      }
      if(p1DOWN==true) {
         posY +=paddleSpeed;
      }
      if(p1LEFT==true) {
         posX -= paddleSpeed;
      }
      if(p1RIGHT==true) {
         posX += paddleSpeed;
      }

      void keyPressed()  {

         if (key=='w' || key=='W') {
            p1UP = true;
         }
         if (key=='s' || key=='S') {
            p1DOWN = true;
         }  
         if (key=='a' || key=='A') {
            p1LEFT = true;
         }
         if (key=='d' || key=='D') {
            p1RIGHT = true;
         }
      } 

      void keyReleased()  {

         if (key=='w' || key=='W') {
            p1UP = false;
         }
         if (key=='s' || key=='S') {
            p1DOWN = false;
         }  
         if (key=='a' || key=='A') {
            p1LEFT = false;
         }
         if (key=='d' || key=='D') {
            p1RIGHT = false;
         }
      } 
   }
}

This makes it obvious that your keyPressed() and keyReleased() functions are inside your draw() function, which isn't valid.
Also note that this line is pretty egregious:
if (keyPressed) level=1;

Even though it's not causing anything bad now, if down the road you want to do more than just set the level equal to 1, you're more likely to introduce logical errors. For that reason, if statements should always be followed by curly brackets, even if they're only one statement:
if (keyPressed){
    level=1;
}

