I am trying to write a game, and if they do something, it will launch the on-screen keyboard. Then, if they touch several keys, the game will change the scene to the bonus level. I am currently using libgdx and it works fine on the desktop version with a real keyboard. I can not get it to work on the Android version.
In the rendering 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 thing is to show the keyboard. That's what it is. However, when I try to detect a keystroke:
if (Gdx.input.isKeyPressed(Keys.A)) { // Do What I need it to do. }
I never get true value. No matter what key or value. How to detect keystrokes on an Android on-screen keyboard in libGDX?
source share