What is the android key-code for exclamation mark ? (!)

1.3k views Asked by At

I was wondering if someone knows the key-code code for ! in android

2

There are 2 answers

0
Ted Hopp On

It's a bit obscure, but this thread on Google groups provides the answer for a question mark:

KeyEvent.KEYCODE_SLASH, plus true for isShiftPressed()

I assume the same thing will work for an exclamation mark: KeyEvent.KEYCODE_1, plus true for isShiftPressed()

0
Grant Ojanen On

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() == '!'