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

[Android] onKeyPress event not fired with numeric keys #29046

Closed
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,13 @@ public boolean deleteSurroundingText(int beforeLength, int afterLength) {
@Override
public boolean sendKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
boolean isNumberKey = event.getUnicodeChar() < 58 && event.getUnicodeChar() > 47;
if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
dispatchKeyEvent(BACKSPACE_KEY_VALUE);
} else if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
dispatchKeyEvent(ENTER_KEY_VALUE);
} else if (isNumberKey) {
dispatchKeyEvent(String.valueOf(event.getNumber()));
}
}
return super.sendKeyEvent(event);
Expand Down