Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Ctrl keycodes on Android #7189

Open
1 of 6 tasks
M374LX opened this issue Jul 19, 2023 · 0 comments · May be fixed by #7191
Open
1 of 6 tasks

Wrong Ctrl keycodes on Android #7189

M374LX opened this issue Jul 19, 2023 · 0 comments · May be fixed by #7191

Comments

@M374LX
Copy link

M374LX commented Jul 19, 2023

Issue details

According to https://libgdx.com/wiki/misc/adding-new-keycodes, the keycodes used by libGDX should be the same as in Android's KeyEvent class. However, this is not the case of the two Control (Ctrl) keys.

As seen in

public static final int CONTROL_LEFT = 129;
public static final int CONTROL_RIGHT = 130;

CONTROL_LEFT and CONTROL_RIGHT are defined as 129 and 130, respectively. However, Android's KeyEvent class uses different values. As we can see in https://developer.android.com/reference/android/view/KeyEvent, the values for KEYCODE_CTRL_LEFT and KEYCODE_CTRL_RIGHT are 113 and 114. For this reason, Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) and Gdx.input.isKeyPressed(Keys.CONTROL_RIGHT) do not work correctly on Android, although these work correctly on desktop due to the method getGdxKeyCode() in the class DefaultLwjgl3Input.

Reproduction steps/code

A simple program that handles keyboard events by displaying the keycodes is enough. The problem can be noticed when connecting a USB keyboard to an Android phone (with the help of a USB to USB Mini adapter if necessary) and pressing any of the two Ctrl keys. The displayed keycodes will be different depending on whether the program is running on Android or desktop.

Version of libGDX and/or relevant dependencies

1.12.0

Please select the affected platforms

  • Android
  • iOS
  • HTML/GWT
  • Windows
  • Linux
  • macOS
@M374LX M374LX linked a pull request Jul 20, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant