The virtual or soft keyboard on an Android device needs to be opened and closed with the openKeyboard() and closeKeyboard() functions. Once the keyboard is open, all the keyboard functions and variables from Processing can be used.
boolean keyboard = false;
void setup() {
fullScreen();
textFont(createFont("SansSerif", 40 * displayDensity));
fill(0);
}
void draw() {
background(255);
text(key, width/2, height/2);
}
void keyPressed() {
background(200, 50, 30);
}
void mousePressed() {
if (!keyboard) {
openKeyboard();
keyboard = true;
} else {
closeKeyboard();
keyboard = false;
}
}