java - Reading a KeyDown only once in while loop (Like KeyListener in Swing) -


in while loop opengl program have this:

     if (keyboard.iskeydown(keyboard.key_w)) {      ...      } 

now of course if getting checked multiple times per button press.
there way let detect button once per press?
example keylistener in java swing does.

i handle movement speed elapsedtimevariable, maybe can use problem too?

keep track of when comes down first time , when goes up, ideally boolean not defined in local scope of method called 60 times second, @ higher scope.

if (wkeyup && keyboard.iskeydown(keyboard.key_w)) {     wkeyup = false;     onnewwkeypress(); } else if (wkeyup == false) {     wkeyup = true; } 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -