Example usage for com.badlogic.gdx Input isKeyJustPressed

List of usage examples for com.badlogic.gdx Input isKeyJustPressed

Introduction

In this page you can find the example usage for com.badlogic.gdx Input isKeyJustPressed.

Prototype

public boolean isKeyJustPressed(int key);

Source Link

Document

Returns whether the key has just been pressed.

Usage

From source file:de.cubicvoxel.openspacebox.input.KeyboardInputHandler.java

License:Open Source License

@Override
void handleInput(float deltaTime) {
    Input input = Gdx.input;

    float x = 0, y = 0;
    if (input.isKeyPressed(Input.Keys.A))
        x -= 1.0f;/*from   w  w w  .j a  v a2  s  .co m*/
    if (input.isKeyPressed(Input.Keys.D))
        x += 1.0f;
    if (input.isKeyPressed(Input.Keys.W))
        y += 1.0f;
    if (input.isKeyPressed(Input.Keys.S))
        y -= 1.0f;
    if (x != 0 || y != 0)
        postMoveInputEventWithClampedInput(x, y, deltaTime);

    if (input.isKeyJustPressed(Input.Keys.BACKSPACE))
        inputEventBus.post(new BackInputEvent(deltaTime));
}