How to make keyPressed work inside a while loop

Hi Yamin,

You need to handle that in the keyPressed() function in the code I posted.

What you want to do is check if the answer is correct every time a key is pressed. If the answer is correct then you change the state (aka you go to the next question). Otherwise you don’t and the same question stays.

You can check out this thread, the logic is the same: Quiz game - need help