I want set a Boolean to be true when a button is pressed that is essential to make false when the same button is released.
public boolean keyDown (int keycode) {
switch (keycode) {
case Keys.RIGHT:
player.movingRight = True;
//or
//player.xVel = 1;
break;
public boolean keyUp (int keycode) {
switch (keycode) {
case Keys.RIGHT:
player.movingRight = False;
//or
//player.xVel = 0;
break;
Is this a safe method of achieving the results one would desire, or will there ever be a case that the Boolean is left at True?
I think that this method is safe.
What are the available cases to think about?!
Whenever we keyDown we set it to true and whenever we KeyUp we set it to false.
BUT
In my opinion using isKeyPressed or isKeyJustPressed is the best way to achieve what you want.
Check out this article about the difference.