veenarose
veenarose

Reputation: 61

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

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

Upvotes: 0

Views: 1630

Answers (2)

Grant Ojanen
Grant Ojanen

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

Ted Hopp
Ted Hopp

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 for isShiftPressed()

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

Upvotes: 1

Related Questions