1

I have a View that overrides the OnKeyDown event. I can get the Key Code and the KeyEvent, but it seems that I'm missing something.

Let me explain. For non-US keyboard layouts, the Key Code I'm getting is wrong. For example, when I press the ñ key in my Spanish keyboard, I expect to receive a "ñ" letter, but instead I get a Keycode.AltLeft as Key Code.

How do I get the real letter?

Another problematic case is with accentuated characters: When I press the ´ key and the o key, I shouldn't receive two events, but only one with the letter ó.

3
  • "I expect to receive a "ñ" letter -- there is no KEYCODE_ value for all characters in all languages. When you call getUnicodeChar() on the KeyEvent, what do you get back? "When I press the ´ key and the o key, I shouldn't receive two events" -- why do you think this? After all, the documentation for getDeadChar() would seem to disagree with you. Jun 14, 2017 at 18:39
  • "When you call getUnicodeChar() on the KeyEvent, what do you get back?" I get a 0 (zero)
    – SuperJMN
    Jun 14, 2017 at 18:53
  • OK, you're right :) I have just tested and the ´ key doesn't fire the KeyPress event. It fires only when the "o" is pressed afterwards. But with the getUnicodeChar you mention I get a 111 instead of 243 (the Unicode for the "ó")
    – SuperJMN
    Jun 14, 2017 at 19:00

1 Answer 1

0

What are you trying to do? It is probably too low level. A key down might not necessarily have anything to do with the final input text produced. For instance to produce on Japanese character one has to press a sequence of several keys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.