how to take input From Key Board in Java Processing Example



int rec=0;

void setup()
{
size(200,200);

background(156,45,0);
//fill(0);
//rect(20,20,width/2,height/2);

}




/*

################################################
   
   
                drawEllips()  function


################################################

*/




void drawEllips()
{
  background(6,45,0);
fill(0);
ellipse(width/2,height/2,150,150);

}


/*

################################################
   
   
                DrawRect()  function


################################################

*/

void DrawRect()
{
 
background(156,0,50);
fill(255);
rect(20,20,width/2,height/2);

}

void keyPressed()                //  Key Press Function

{
if(key=='\n')          //   Press 'Enter' the Show Ellipse
{

 rec=1;
}
if(key=='s')            //    Press 'S' Show  Rect
{
    rec=2;
 
}
}
void draw()
{

if(rec==1)
{
drawEllips();

}

if(rec==2)
{
DrawRect();

}
}