What is the difference? public boolean onKeyDown (int keyCode, KeyEvent event) The parameters are keyCode,the button,the user pressed,but what is that KeyEvent?
KeyEvent: Each key press is described by a sequence of key events, Key events are generally accompanied by a key code.
KeyCode
: is a constant that define the event, and is defined inside KeyEvent
Class.
For example if you want to detect the KeyEvent "ENTER" :
@Override
public boolean onKeyDown( int keyCode, KeyEvent event ) {
if( keyCode == KeyEvent.KEYCODE_ENTER) {
//Do something...
return true;
}
return super.onKeyDown( keyCode, event );
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With