in case why you're wondering why you have to do it this way.. it's because of the system's keyboard-repeat setting. You'll notice the same delay for any key you press in, say, a word processing program. If there was no delay, you might hold the space key for half a second and end up with 10 spaces
the KeyEvent events are fired as fast as the keyboard-repeat rate is set to. So the boolean flag might keep getting set to the same value several times, but like oNyx is saying, you can check the flag in your loop any time you want.