Gomathi
Gomathi

Reputation: 43

Android - How to get KeyEvent KeyCode to Char?

I want to get the char value of the KeyCode Event when pressing an Android keyboard.

Example :

    @Override
public boolean onKeyUp(int keyCode,  android.view.KeyEvent event) {
    //InputConnection ic = getCurrentInputConnection();

//  Toast.makeText(this, "KEYVALUE"+String.valueOf(KeyEvent.KEYCODE_A), Toast.LENGTH_SHORT).show();
    Log.i("key pressed", String.valueOf(event.getKeyCode()));

    return onKeyDown(keyCode, event);
}

Note : I got value number but i did not get value character.

Upvotes: 2

Views: 3518

Answers (1)

Moumou
Moumou

Reputation: 1532

char unicodeChar = (char)event.getUnicodeChar();

Upvotes: 3

Related Questions