Spectre Spectre - 4 months ago 63
Android Question

LibGDX - how to catch a backbutton inside a TextField with Android Keyboard visible?

I'm trying to catch the Back button while the TextField is focused (keyboard is visible).

I have already tried with

- setting the '
' on the top of the stages - it doesn't work:

InputProcessor backProcessor = new InputAdapter() {
public boolean keyDown(int keycode) {

if ((keycode == Input.Keys.BACK) )
Gdx.app.log("INPUT", "BACK");
return false;

InputMultiplexer multiplexer = new InputMultiplexer(backProcessor,

Also, I tried in the
method with:


Doesn't work too.

Above solutions work perfectly EXCEPT the moment, when the keyboard is visible.

What I'm trying to achieve?
I need to catch the Back Button when the onScreenKeyboard is visible.


I also tried with
but 'BackButton' is the one key that hasn't any 'char code' so it can't be catched there:

public void keyTyped(TextField textField, char c)


As LibGDX authors said - there's no way to retrieve this in a normal way cause the back button is proccessed outside of application while it's pressed when keyboard is visible. Android solution is to override
but LibGDX
has nothing to do with Android's one and there's no connection.

If there's anyone that could point any solution to this problem, I'd be grateful.


The answer is - impossible. Android doesn't catch the back button while keyboard is active. Ha. They don't even have a way to check if soft-keyboard is visible and there are tricks to catch it's view's height (which gives the keyboard height) which also makes everything wrong because it collides with other ui components like navigation/status bar and the whole immersive mode.

I hope that someday some Google Dev will look here, check this and think about fixing this after 6 years, because we're in 2016 and you're fixing code-style instead of critical bugs which are posted on tracker by greatest coders from here.