Skip to content

Predictive back gesture does not fire keyUp event #7830

Description

@LobbyDivinus

Describe the bug

PR #7429 added support for predictive back gestures. That is a special way of triggering the back key via a gesture on Android. In contrast to the previous implementation - and my expectation on how it would work - it does not fire a keyUp event.

From my understanding the solution would be to also fire a KEY_UP event in the OnBackInvokedCallback.onBackInvoked() implementation:

KeyEvent event = new KeyEvent();
event.timeStamp = System.nanoTime();
event.type = KeyEvent.KEY_DOWN;
event.keyCode = Keys.BACK;
event.keyChar = 0;
keyEvents.add(event);

Reproduction

The main difficulty may be to know if your device is even using predictive back gestures.

Here's a setup to create a test bed:

    Gdx.input.setCatchKey(Input.Keys.BACK, true)
    Gdx.input.setInputProcessor(new InputAdapter() {

        @Override
        public boolean keyDown(int keycode) {
            Gdx.app.debug("input", "keyDown: " + Input.Keys.toString(keycode));
            return true;
        }

        @Override
        public boolean keyUp(int keycode) {
            Gdx.app.debug("input", "keyUp: " + Input.Keys.toString(keycode));
            return true;
        }

    });

On my test device (only using gesture back button) it outputs:
[input] keyDown: Back
[input] keyDown: Back
[input] keyDown: Back
...

While I would expect it to output:
[input] keyDown: Back
[input] keyUp: Back
[input] keyDown: Back
[input] keyUp: Back
[input] keyDown: Back
[input] keyUp: Back
...

version

1.13.0+

Affected platforms

  • Android
  • iOS
  • HTML/GWT
  • Windows
  • Linux
  • macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions