Skip to content

Commit

Permalink
Remove minimum delay for key release
Browse files Browse the repository at this point in the history
  • Loading branch information
woesss committed Jul 14, 2024
1 parent 177c985 commit 5d18a8b
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions app/src/main/java/javax/microedition/lcdui/Canvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -969,17 +969,17 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
return onKeyUp(keyCode, event);
}
case KeyEvent.ACTION_MULTIPLE -> {
if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
String characters = event.getCharacters();
for (int i = 0; i < characters.length(); i++) {
int cp = characters.codePointAt(i);
postKeyPressed(cp);
postKeyReleased(cp);
}
return true;
} else {
if (keyCode != KeyEvent.KEYCODE_UNKNOWN) {
return onKeyDown(keyCode, event);
}
String characters = event.getCharacters();
for (int i = 0, len = characters.length(); i < len; ) {
int cp = characters.codePointAt(i);
postKeyPressed(cp);
postKeyReleased(cp);
i += Character.charCount(cp);
}
return true;
}
}
return false;
Expand Down Expand Up @@ -1007,17 +1007,8 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
if (midpKeyCode == 0) {
return false;
}
long pressedTime = event.getEventTime() - event.getDownTime();
if (pressedTime < 100) {
mView.postDelayed(() -> {
if (overlay == null || !overlay.keyReleased(midpKeyCode)) {
postKeyReleased(midpKeyCode);
}
}, 100 - pressedTime);
} else {
if (overlay == null || !overlay.keyReleased(midpKeyCode)) {
postKeyReleased(midpKeyCode);
}
if (overlay == null || !overlay.keyReleased(midpKeyCode)) {
postKeyReleased(midpKeyCode);
}
return true;
}
Expand Down

0 comments on commit 5d18a8b

Please sign in to comment.