Reputation: 61
I was wondering if someone knows the key-code code for ! in android
Upvotes: 0
Views: 1630
Reputation: 188
Since ! and 1 are on the same key, you would want to check for the KeyEvent
's Unicode Character not its key-code. This probably is a better way to catch the exclamation mark, because some keyboard layouts may not have ! and 1 on the same key.
keyevent.getUnicodeChar() == '!'
Upvotes: 0
Reputation: 234847
It's a bit obscure, but this thread on Google groups provides the answer for a question mark:
KeyEvent.KEYCODE_SLASH
, plus true forisShiftPressed()
I assume the same thing will work for an exclamation mark: KeyEvent.KEYCODE_1
, plus true for isShiftPressed()
Upvotes: 1