Android - How to convert KeyEvent KeyCode to Char?

android

Solution

> I had already answered updating the question

// TODO: convert key Code Event into char
char pressedKey = (char) event.getUnicodeChar();

IMPORTANT NOTE: char has only 1 byte length, so it will not support several chars

Hope it help you somehow

Problem

I want to get the char value of the KeyCode Event when pressing an Android keyboard. ``` public void KeyCodeEventAsChar(int keyCode, KeyEvent event) { char pressedKey; // TODO: convert key Code Event into char syslog.d ("TEST", "The pressed key in Android keyboard was char: " + pressedKey); } ``` Does anyone has a clue how to do this?! UPDATE: I don't want hardcoded text! I want to convert it to correspondent char! UPDATE 2: I need also to dead chars such as: à, á, ò, ó, etc... ANSWER FOUND: ``` // TODO: convert key Code Event into char char pressedKey = (char) event.getUnicodeChar(); ``` IMPORTANT NOTE: char has only 1 byte length, so it will not support several chars

Original source

Related problems