many ways. one will be:
char state;
void example() {
while('4' != state) { //if you read input from serial monitor it will be char type
Serial.printlc("wait for you to press 4");
state = Serial.read();//assuming you read intput from serial
delay(100);
}
}
Ond use code editor tag instead os screen shot.. It more easier to read.