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

c# - HttpResponseMessage System.InvalidOperationException -

sql - Postgresql error: "failed to find conversion function from unknown to text" -