I am trying to write a game and if they do something it will start up the onscreen keyboard. Then, if they touch a few keys the game will change scenes to a bonus level. I am currently using libgdx and it works great on the desktop version with a real keyboard. I cannot get it to work on the android version.
In the render method:
if (Gdx.input.isTouched()) {
Vector3 touchPos = new Vector3();
touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
camera.unproject(touchPos);
...
} else if (touchPos.x > 0 && touchPos.x < 200
&& touchPos.y > 0 && touchPos.y < 50) {
Gdx.input.setOnscreenKeyboardVisible(true);
}
This works great. The entire point of this is to get the keyboard to show up. That it does do. However, when I try to detect a key press with:
if (Gdx.input.isKeyPressed(Keys.A)) {
// Do What I need it to do.
}
I do not get a true value for this ever. No matter what key or value. How do I detect key presses from an on-screen Android keyboard in libGDX?