Example usage for android.view KeyEvent getCharacters

List of usage examples for android.view KeyEvent getCharacters

Introduction

In this page you can find the example usage for android.view KeyEvent getCharacters.

Prototype

public final String getCharacters() 

Source Link

Document

For the special case of a #ACTION_MULTIPLE event with key code of #KEYCODE_UNKNOWN , this is a raw string of characters associated with the event.

Usage

From source file:org.godotengine.godot.Godot.java

@Override
public boolean onKeyMultiple(final int inKeyCode, int repeatCount, KeyEvent event) {
    String s = event.getCharacters();
    if (s == null || s.length() == 0)
        return super.onKeyMultiple(inKeyCode, repeatCount, event);

    final char[] cc = s.toCharArray();
    int cnt = 0;/* w  w  w  . j av  a2s .  c  om*/
    for (int i = cc.length; --i >= 0; cnt += cc[i] != 0 ? 1 : 0)
        ;
    if (cnt == 0)
        return super.onKeyMultiple(inKeyCode, repeatCount, event);
    final Activity me = this;
    queueEvent(new Runnable() {
        // This method will be called on the rendering thread:
        public void run() {
            for (int i = 0, n = cc.length; i < n; i++) {
                int keyCode;
                if ((keyCode = cc[i]) != 0) {
                    // Simulate key down and up...
                    GodotLib.key(0, keyCode, true);
                    GodotLib.key(0, keyCode, false);
                }
            }
        }
    });
    return true;
}

From source file:com.duy.pascal.ui.view.console.ConsoleView.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.isSystem()) {
        return super.onKeyDown(keyCode, event);
    }/*from  w  ww.ja v a  2 s  .c  o  m*/
    mKeyBuffer.push((char) event.getUnicodeChar()); //scan code

    if (keyCode == KeyEvent.KEYCODE_DEL) {
        putString(THE_DELETE_COMMAND);
        return true;
    }
    String c = event.getCharacters();
    if (c == null) {
        c = Character.valueOf((char) event.getUnicodeChar()).toString();
    }
    putString(c);
    return true;
}