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 elapsedtime
variable, 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
Post a Comment