Ah, yes and no. It’s probably best if you write your own key managed so that you can really manage how it works. Especially with the key repeat stuff some computers have.
I use something like this:
public enum KeyCommand {
SHOOT(10);
private final int repeat;
private int countDown;
private boolean armed;
KeyCommand(int repeat) {
this.repeat = repeat;
}
public void updatePressed(boolean pressed) {
countDown--;
if (pressed) {
if (countDown < 0) {
armed = true;
countDown = repeat;
}
}
}
public boolean isArmed() {
return armed;
}
public void resetArmed() {
armed = false;
}
}
KeyCommand.SHOOT.Input.isKeyDown(SHOOT_KEY));
if(KeyCommand.SHOOT.isArmed()) {
//shoot code
KeyCommand.SHOOT.resetArmed();
}
The int value to the enum constructor sets how many frames can pass before another keypress/instance of the key being down, causes it to be ‘armed’ again. So that if you’re mashing the key or you’re holding it down or you’re pressing when you’re ready, it shouldn’t allow you to have a beam-spam.