I\'m new to Android development and I can\'t seem to find a good guide on how to use an onKeyUp listener.
In my app, I have a big EditText,
You may consider using the following code:
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch (keyCode) {
...
case KeyEvent.KEYCODE_J:
if (event.isShiftPressed()) {
fireLaser();
} else {
fireMachineGun();
}
return true;
case KeyEvent.KEYCODE_K:
if (event.isShiftPressed()) {
fireSeekingMissle();
} else {
fireMissile();
}
return true;
default:
return super.onKeyUp(keyCode, event);
} }
Here In the end we have called the super.onkeyUp method. Which handles the event when the user do not presses the valid key.
For more details you may consider following link.