Reputation: 2073
In the View.OnKeyListener interface, there is a method defined like this:
abstract boolean onKey(View v, int keyCode, KeyEvent event)
What is the difference between the keyCode paramater, and event.getKeyCode()?
Why is there 2 keyCodes?
Upvotes: 1
Views: 130
Reputation: 66989
The keyCode
value is the same as the event.getKeyCode()
value.
The KeyEvent
contains full information about the key event, including the key code that caused the event.
I suspect that the keyCode
parameter was included in the onKey()
method signature because it just made sense to include the most salient information. Also, there are probably a lot of callback implementations that only need the key code.
Upvotes: 2