I'm trying to make a keyboard...
int code = 29; // Key code constant: 'A' key. Constant Value: 29 (0x0000001d)
KeyEvent k = new KeyEvent(KeyEvent.ACTION_UP, code);
InputConnection ic = getCurrentInputConnection();
ic.sendKeyEvent(k);
This code nicely send letter "A" to the application, as it is associated with the code "29", as from here http://developer.android.com/reference/android/view/KeyEvent.html
But what should I do, if I want to use unicode characters, such as in here
http://en.wikipedia.org/wiki/List_of_Unicode_characters
If you are building a keyboard app, and have keyboard layout in xml, you can look at suggestion provided by user Laurent' in another thread:
<Key android:codes="946" android:keyLabel="\u03B2"/>
<Key android:codes="946" android:keyLabel="&946;"/>
<Key android:codes="946" android:keyLabel="β"/>
<!-- Warning, you should use UTF-8 encoding for your project files if you use the third solution -->
<!-- all produce the same key with greek β character (unicode \u03B2, decimal 946) -->
Please check the softkeyboard sample code.
If you are developing a new keyboard(for example for any other language), change the android:code attribute value to the unicode value which you want the keyboard to output. This works fine and I think you can test it in the same softkeyboard project.
User contributions licensed under CC BY-SA 3.0