I have this code in my update()
if(Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState()){
System.out.println("true");
But when I press T it prints 4 times I want it to print only 1 time.
How can I solve this???
I have this code in my update()
if(Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState()){
System.out.println("true");
But when I press T it prints 4 times I want it to print only 1 time.
How can I solve this???
boolean keydown = false;
public void method(){
if(!keydown && Input.getInput().isKeyDown(KeyEvent.VK_ENTER)){
keydown = true;
}
if(!Input.getInput().checkForKeyPress()){
keydown = false;
}
}
Use a boolean to stop the input from falling through the if statement.
Reset it to false when the input is no longer in. This way, when you hold the key down, it sets keydown to true, and stays that way until you are no longer pressing keys.
I am going to test that right now.
Thanks it worked!!!
nice. It works for mouse too. I have my input handler deal with individual keys like that, using the keycodes and a boolean[].