Code example for KeyEvent

Methods: getActiongetEventTimegetKeyCodegetMetaStategetUnicodeCharisSystem

    boolean translateAndSendNativeEvents(KeyEvent event) {
        if (mNativeImeAdapterAndroid == 0) return false;
        int action = event.getAction();
        if (action != KeyEvent.ACTION_DOWN &&
            action != KeyEvent.ACTION_UP) {
            // action == KeyEvent.ACTION_MULTIPLE 
            // TODO(bulach): confirm the actual behavior. Apparently: 
            // If event.getKeyCode() == KEYCODE_UNKNOWN, we can send a 
            // composition key down (229) followed by a commit text with the 
            // string from event.getUnicodeChars(). 
            // Otherwise, we'd need to send an event with a 
            // WebInputEvent::IsAutoRepeat modifier. We also need to verify when 
            // we receive ACTION_MULTIPLE: we may receive it after an ACTION_DOWN, 
            // and if that's the case, we'll need to review when to send the Char 
            // event. 
            return false; 
        return nativeSendKeyEvent(mNativeImeAdapterAndroid, event, event.getAction(),
                getModifiers(event.getMetaState()), event.getEventTime(), event.getKeyCode(),
                                event.isSystem(), event.getUnicodeChar());
    boolean sendSyntheticKeyEvent( 
            int eventType, long timestampMs, int keyCode, int unicodeChar) {
        if (mNativeImeAdapterAndroid == 0) return false;
Contextual code suggestions in your IDE  Get Codota for Java