Java Code Examples for android.view.KeyEvent#META_ALT_ON

The following examples show how to use android.view.KeyEvent#META_ALT_ON . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImeAdapter.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private static int getModifiers(int metaState) {
    int modifiers = 0;
    if ((metaState & KeyEvent.META_SHIFT_ON) != 0) {
      modifiers |= sModifierShift;
    }
    if ((metaState & KeyEvent.META_ALT_ON) != 0) {
      modifiers |= sModifierAlt;
    }
    if ((metaState & KeyEvent.META_CTRL_ON) != 0) {
      modifiers |= sModifierCtrl;
    }
    if ((metaState & KeyEvent.META_CAPS_LOCK_ON) != 0) {
      modifiers |= sModifierCapsLockOn;
    }
    if ((metaState & KeyEvent.META_NUM_LOCK_ON) != 0) {
      modifiers |= sModifierNumLockOn;
    }
    return modifiers;
}
 
Example 2
Source File: DefaultKeyComboModel.java    From talkback with Apache License 2.0 6 votes vote down vote up
private void loadTriggerModifierFromPreferences() {
  SharedPreferences prefs = SharedPreferencesUtils.getSharedPreferences(mContext);
  int defaultTriggerModifier =
      mIsArc
          ? R.string.trigger_modifier_meta_entry_value
          : R.string.trigger_modifier_alt_entry_value;

  if (!prefs.contains(getPreferenceKeyForTriggerModifier())) {
    // Store default value in preferences to show it in preferences UI.
    prefs
        .edit()
        .putString(
            getPreferenceKeyForTriggerModifier(), mContext.getString(defaultTriggerModifier))
        .apply();
  }

  String triggerModifier =
      prefs.getString(
          getPreferenceKeyForTriggerModifier(), mContext.getString(defaultTriggerModifier));
  if (triggerModifier.equals(mContext.getString(R.string.trigger_modifier_alt_entry_value))) {
    mTriggerModifier = KeyEvent.META_ALT_ON;
  } else if (triggerModifier.equals(
      mContext.getString(R.string.trigger_modifier_meta_entry_value))) {
    mTriggerModifier = KeyEvent.META_META_ON;
  }
}
 
Example 3
Source File: ImeAdapter.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private static int getModifiers(int metaState) {
    int modifiers = 0;
    if ((metaState & KeyEvent.META_SHIFT_ON) != 0) {
        modifiers |= WebInputEventModifier.SHIFT_KEY;
    }
    if ((metaState & KeyEvent.META_ALT_ON) != 0) {
        modifiers |= WebInputEventModifier.ALT_KEY;
    }
    if ((metaState & KeyEvent.META_CTRL_ON) != 0) {
        modifiers |= WebInputEventModifier.CONTROL_KEY;
    }
    if ((metaState & KeyEvent.META_CAPS_LOCK_ON) != 0) {
        modifiers |= WebInputEventModifier.CAPS_LOCK_ON;
    }
    if ((metaState & KeyEvent.META_NUM_LOCK_ON) != 0) {
        modifiers |= WebInputEventModifier.NUM_LOCK_ON;
    }
    return modifiers;
}
 
Example 4
Source File: ImeAdapter.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private static int getModifiers(int metaState) {
    int modifiers = 0;
    if ((metaState & KeyEvent.META_SHIFT_ON) != 0) {
      modifiers |= sModifierShift;
    }
    if ((metaState & KeyEvent.META_ALT_ON) != 0) {
      modifiers |= sModifierAlt;
    }
    if ((metaState & KeyEvent.META_CTRL_ON) != 0) {
      modifiers |= sModifierCtrl;
    }
    if ((metaState & KeyEvent.META_CAPS_LOCK_ON) != 0) {
      modifiers |= sModifierCapsLockOn;
    }
    if ((metaState & KeyEvent.META_NUM_LOCK_ON) != 0) {
      modifiers |= sModifierNumLockOn;
    }
    return modifiers;
}
 
Example 5
Source File: KeyEventCompat.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int normalizeMetaState(int metaState) {
    if ((metaState & (KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_RIGHT_ON)) != 0) {
        metaState |= KeyEvent.META_SHIFT_ON;
    }
    if ((metaState & (KeyEvent.META_ALT_LEFT_ON | KeyEvent.META_ALT_RIGHT_ON)) != 0) {
        metaState |= KeyEvent.META_ALT_ON;
    }
    return metaState & META_ALL_MASK;
}
 
Example 6
Source File: MenuBuilder.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) {
    // Get all items that can be associated directly or indirectly with the keyCode
    ArrayList<MenuItemImpl> items = mTempShortcutItemList;
    items.clear();
    findItemsWithShortcutForKey(items, keyCode, event);

    if (items.isEmpty()) {
        return null;
    }

    final int metaState = event.getMetaState();
    final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
    // Get the chars associated with the keyCode (i.e using any chording combo)
    event.getKeyData(possibleChars);

    // If we have only one element, we can safely returns it
    final int size = items.size();
    if (size == 1) {
        return items.get(0);
    }

    final boolean qwerty = isQwertyMode();
    // If we found more than one item associated with the key,
    // we have to return the exact match
    for (int i = 0; i < size; i++) {
        final MenuItemImpl item = items.get(i);
        final char shortcutChar = qwerty ? item.getAlphabeticShortcut() :
                item.getNumericShortcut();
        if ((shortcutChar == possibleChars.meta[0] &&
                (metaState & KeyEvent.META_ALT_ON) == 0)
            || (shortcutChar == possibleChars.meta[2] &&
                (metaState & KeyEvent.META_ALT_ON) != 0)
            || (qwerty && shortcutChar == '\b' &&
                keyCode == KeyEvent.KEYCODE_DEL)) {
            return item;
        }
    }
    return null;
}
 
Example 7
Source File: MenuBuilder.java    From zhangshangwuda with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) {
    // Get all items that can be associated directly or indirectly with the keyCode
    ArrayList<MenuItemImpl> items = mTempShortcutItemList;
    items.clear();
    findItemsWithShortcutForKey(items, keyCode, event);

    if (items.isEmpty()) {
        return null;
    }

    final int metaState = event.getMetaState();
    final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
    // Get the chars associated with the keyCode (i.e using any chording combo)
    event.getKeyData(possibleChars);

    // If we have only one element, we can safely returns it
    final int size = items.size();
    if (size == 1) {
        return items.get(0);
    }

    final boolean qwerty = isQwertyMode();
    // If we found more than one item associated with the key,
    // we have to return the exact match
    for (int i = 0; i < size; i++) {
        final MenuItemImpl item = items.get(i);
        final char shortcutChar = qwerty ? item.getAlphabeticShortcut() :
                item.getNumericShortcut();
        if ((shortcutChar == possibleChars.meta[0] &&
                (metaState & KeyEvent.META_ALT_ON) == 0)
            || (shortcutChar == possibleChars.meta[2] &&
                (metaState & KeyEvent.META_ALT_ON) != 0)
            || (qwerty && shortcutChar == '\b' &&
                keyCode == KeyEvent.KEYCODE_DEL)) {
            return item;
        }
    }
    return null;
}
 
Example 8
Source File: MenuBuilder.java    From zen4android with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) {
    // Get all items that can be associated directly or indirectly with the keyCode
    ArrayList<MenuItemImpl> items = mTempShortcutItemList;
    items.clear();
    findItemsWithShortcutForKey(items, keyCode, event);

    if (items.isEmpty()) {
        return null;
    }

    final int metaState = event.getMetaState();
    final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
    // Get the chars associated with the keyCode (i.e using any chording combo)
    event.getKeyData(possibleChars);

    // If we have only one element, we can safely returns it
    final int size = items.size();
    if (size == 1) {
        return items.get(0);
    }

    final boolean qwerty = isQwertyMode();
    // If we found more than one item associated with the key,
    // we have to return the exact match
    for (int i = 0; i < size; i++) {
        final MenuItemImpl item = items.get(i);
        final char shortcutChar = qwerty ? item.getAlphabeticShortcut() :
                item.getNumericShortcut();
        if ((shortcutChar == possibleChars.meta[0] &&
                (metaState & KeyEvent.META_ALT_ON) == 0)
            || (shortcutChar == possibleChars.meta[2] &&
                (metaState & KeyEvent.META_ALT_ON) != 0)
            || (qwerty && shortcutChar == '\b' &&
                keyCode == KeyEvent.KEYCODE_DEL)) {
            return item;
        }
    }
    return null;
}
 
Example 9
Source File: KeyEventCompat.java    From guideshow with MIT License 5 votes vote down vote up
@Override
public int normalizeMetaState(int metaState) {
    if ((metaState & (KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_RIGHT_ON)) != 0) {
        metaState |= KeyEvent.META_SHIFT_ON;
    }
    if ((metaState & (KeyEvent.META_ALT_LEFT_ON | KeyEvent.META_ALT_RIGHT_ON)) != 0) {
        metaState |= KeyEvent.META_ALT_ON;
    }
    return metaState & META_ALL_MASK;
}
 
Example 10
Source File: KeyEventCompat.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
@Override
public int normalizeMetaState(int metaState) {
    if ((metaState & (KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_RIGHT_ON)) != 0) {
        metaState |= KeyEvent.META_SHIFT_ON;
    }
    if ((metaState & (KeyEvent.META_ALT_LEFT_ON | KeyEvent.META_ALT_RIGHT_ON)) != 0) {
        metaState |= KeyEvent.META_ALT_ON;
    }
    return metaState & META_ALL_MASK;
}
 
Example 11
Source File: KeyEventCompat.java    From android-recipes-app with Apache License 2.0 5 votes vote down vote up
@Override
public int normalizeMetaState(int metaState) {
    if ((metaState & (KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_RIGHT_ON)) != 0) {
        metaState |= KeyEvent.META_SHIFT_ON;
    }
    if ((metaState & (KeyEvent.META_ALT_LEFT_ON | KeyEvent.META_ALT_RIGHT_ON)) != 0) {
        metaState |= KeyEvent.META_ALT_ON;
    }
    return metaState & META_ALL_MASK;
}
 
Example 12
Source File: MenuBuilder.java    From android-apps with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) {
    // Get all items that can be associated directly or indirectly with the keyCode
    ArrayList<MenuItemImpl> items = mTempShortcutItemList;
    items.clear();
    findItemsWithShortcutForKey(items, keyCode, event);

    if (items.isEmpty()) {
        return null;
    }

    final int metaState = event.getMetaState();
    final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
    // Get the chars associated with the keyCode (i.e using any chording combo)
    event.getKeyData(possibleChars);

    // If we have only one element, we can safely returns it
    final int size = items.size();
    if (size == 1) {
        return items.get(0);
    }

    final boolean qwerty = isQwertyMode();
    // If we found more than one item associated with the key,
    // we have to return the exact match
    for (int i = 0; i < size; i++) {
        final MenuItemImpl item = items.get(i);
        final char shortcutChar = qwerty ? item.getAlphabeticShortcut() :
                item.getNumericShortcut();
        if ((shortcutChar == possibleChars.meta[0] &&
                (metaState & KeyEvent.META_ALT_ON) == 0)
            || (shortcutChar == possibleChars.meta[2] &&
                (metaState & KeyEvent.META_ALT_ON) != 0)
            || (qwerty && shortcutChar == '\b' &&
                keyCode == KeyEvent.KEYCODE_DEL)) {
            return item;
        }
    }
    return null;
}
 
Example 13
Source File: KeyEventCompat.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
@Override
public int normalizeMetaState(int metaState) {
    if ((metaState & (KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_RIGHT_ON)) != 0) {
        metaState |= KeyEvent.META_SHIFT_ON;
    }
    if ((metaState & (KeyEvent.META_ALT_LEFT_ON | KeyEvent.META_ALT_RIGHT_ON)) != 0) {
        metaState |= KeyEvent.META_ALT_ON;
    }
    return metaState & META_ALL_MASK;
}
 
Example 14
Source File: KeyAssignmentUtils.java    From talkback with Apache License 2.0 5 votes vote down vote up
/**
 * Convert a KeyEvent into a long which can be kept in settings and compared to key presses when
 * the service is in use.
 *
 * @param keyEvent The key event to convert. The (non-extended) keycode must not be a modifier.
 * @return An extended key code that includes modifier information
 */
public static long keyEventToExtendedKeyCode(KeyEvent keyEvent) {
  long returnValue = keyEvent.getKeyCode();
  returnValue |= (keyEvent.isShiftPressed()) ? (((long) KeyEvent.META_SHIFT_ON) << 32) : 0;
  returnValue |= (keyEvent.isCtrlPressed()) ? (((long) KeyEvent.META_CTRL_ON) << 32) : 0;
  returnValue |= (keyEvent.isAltPressed()) ? (((long) KeyEvent.META_ALT_ON) << 32) : 0;
  return returnValue;
}
 
Example 15
Source File: LatinIME.java    From hackerskeyboard with Apache License 2.0 5 votes vote down vote up
private void sendAltKey(InputConnection ic, boolean isDown, boolean chording) {
    if (chording && delayChordingAltModifier()) return;

    int key = sKeyboardSettings.chordingAltKey;
    if (key == 0) key = KeyEvent.KEYCODE_ALT_LEFT;
    int meta = KeyEvent.META_ALT_ON | KeyEvent.META_ALT_LEFT_ON;
    if (isDown) {
        sendKeyDown(ic, key, meta);
    } else {
        sendKeyUp(ic, key, meta);
    }
}
 
Example 16
Source File: LatinIME.java    From hackerskeyboard with Apache License 2.0 5 votes vote down vote up
private int getMetaState(boolean shifted) {
    int meta = 0;
    if (shifted) meta |= KeyEvent.META_SHIFT_ON | KeyEvent.META_SHIFT_LEFT_ON;
    if (mModCtrl) meta |= KeyEvent.META_CTRL_ON | KeyEvent.META_CTRL_LEFT_ON;
    if (mModAlt) meta |= KeyEvent.META_ALT_ON | KeyEvent.META_ALT_LEFT_ON;
    if (mModMeta) meta |= KeyEvent.META_META_ON | KeyEvent.META_META_LEFT_ON;
    return meta;
}
 
Example 17
Source File: MenuBuilder.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) {
    // Get all items that can be associated directly or indirectly with the keyCode
    ArrayList<MenuItemImpl> items = mTempShortcutItemList;
    items.clear();
    findItemsWithShortcutForKey(items, keyCode, event);

    if (items.isEmpty()) {
        return null;
    }

    final int metaState = event.getMetaState();
    final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
    // Get the chars associated with the keyCode (i.e using any chording combo)
    event.getKeyData(possibleChars);

    // If we have only one element, we can safely returns it
    final int size = items.size();
    if (size == 1) {
        return items.get(0);
    }

    final boolean qwerty = isQwertyMode();
    // If we found more than one item associated with the key,
    // we have to return the exact match
    for (int i = 0; i < size; i++) {
        final MenuItemImpl item = items.get(i);
        final char shortcutChar = qwerty ? item.getAlphabeticShortcut() :
                item.getNumericShortcut();
        if ((shortcutChar == possibleChars.meta[0] &&
                (metaState & KeyEvent.META_ALT_ON) == 0)
            || (shortcutChar == possibleChars.meta[2] &&
                (metaState & KeyEvent.META_ALT_ON) != 0)
            || (qwerty && shortcutChar == '\b' &&
                keyCode == KeyEvent.KEYCODE_DEL)) {
            return item;
        }
    }
    return null;
}
 
Example 18
Source File: TerminalKeyboard.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
     * Use this to monitor key events being delivered to the application.
     * We get first crack at them, and can either resume them or let them
     * continue to the app.
     */
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
//        Log.v("SpartacusRex","SOFT : onKeyDown "+ keyCode+" "+event.getMetaState());
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
                // The InputMethodService already takes care of the back
                // key for us, to dismiss the input method if it is shown.
                // However, our keyboard could be showing a pop-up window
                // that back should dismiss, so we first allow it to do that.
                if (event.getRepeatCount() == 0 && mInputView != null) {
                    if (mInputView.handleBack()) {
                        return true;
                    }
                }
                break;

            case KeyEvent.KEYCODE_DEL:
                // Special handling of the delete key: if we currently are
                // composing text for the user, we want to modify that instead
                // of let the application to the delete itself.
                if (mComposing.length() > 0) {
                    onKey(Keyboard.KEYCODE_DELETE, null);
                    return true;
                }
                break;

            case KeyEvent.KEYCODE_ENTER:
                // Let the underlying text editor always handle these.
                return false;

            default:
                // For all other keys, if we want to do transformations on
                // text being entered with a hard keyboard, we need to process
                // it and do the appropriate action.
                if (PROCESS_HARD_KEYS) {
                    if (keyCode == KeyEvent.KEYCODE_SPACE
                            && (event.getMetaState() & KeyEvent.META_ALT_ON) != 0) {
                        // A silly example: in our input method, Alt+Space
                        // is a shortcut for 'android' in lower case.
                        InputConnection ic = getCurrentInputConnection();
                        if (ic != null) {
                            // First, tell the editor that it is no longer in the
                            // shift state, since we are consuming this.
                            ic.clearMetaKeyStates(KeyEvent.META_ALT_ON);
                            keyDownUp(KeyEvent.KEYCODE_A);
                            keyDownUp(KeyEvent.KEYCODE_N);
                            keyDownUp(KeyEvent.KEYCODE_D);
                            keyDownUp(KeyEvent.KEYCODE_R);
                            keyDownUp(KeyEvent.KEYCODE_O);
                            keyDownUp(KeyEvent.KEYCODE_I);
                            keyDownUp(KeyEvent.KEYCODE_D);
                            // And we consume this event.
                            return true;
                        }
                    }
                    if (mPredictionOn && translateKeyDown(keyCode, event)) {
                        return true;
                    }
                }
        }

        return super.onKeyDown(keyCode, event);
    }
 
Example 19
Source File: KeyAssignmentUtils.java    From talkback with Apache License 2.0 4 votes vote down vote up
/**
 * Create a string that describes the extended key code. This string can be shown to the user to
 * indicate the current choice of key.
 *
 * @param extendedKeyCode The key code to describe
 * @param context The current Context
 * @return A description of the key code
 */
public static String describeExtendedKeyCode(long extendedKeyCode, Context context) {
  if (extendedKeyCode == INVALID_EXTENDED_KEY_CODE) {
    return context.getString(R.string.no_key_assigned);
  }

  if (extendedKeyCode == KEYCODE_SCREEN_SWITCH) {
    return context.getString(R.string.name_of_screen_switch);
  }
  /* If meta keys are pressed, build a string to represent this combination of keys */
  StringBuilder keystrokeDescriptionBuilder = new StringBuilder();
  if ((extendedKeyCode & (((long) KeyEvent.META_CTRL_ON) << 32)) != 0) {
    keystrokeDescriptionBuilder.append(
        context.getString(R.string.key_combo_preference_control_plus));
  }
  if ((extendedKeyCode & (((long) KeyEvent.META_ALT_ON) << 32)) != 0) {
    keystrokeDescriptionBuilder.append(context.getString(R.string.key_combo_preference_alt_plus));
  }
  if ((extendedKeyCode & (((long) KeyEvent.META_SHIFT_ON) << 32)) != 0) {
    keystrokeDescriptionBuilder.append(
        context.getString(R.string.key_combo_preference_shift_plus));
  }

  /* Try to obtain a localized representation of the key */
  KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, (int) extendedKeyCode);
  char displayLabel = keyEvent.getDisplayLabel();
  if (displayLabel != 0 && !Character.isWhitespace(displayLabel)) {
    keystrokeDescriptionBuilder.append(displayLabel);
  } else if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_SPACE) {
    keystrokeDescriptionBuilder.append(context.getString(R.string.name_of_space_bar));
  } else if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
    keystrokeDescriptionBuilder.append(context.getString(R.string.name_of_enter_key));
  } else if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_TAB) {
    keystrokeDescriptionBuilder.append(context.getString(R.string.name_of_tab_key));
  } else {
    /* Fall back on non-localized descriptions */
    keystrokeDescriptionBuilder.append(KeyEvent.keyCodeToString((int) extendedKeyCode));
  }

  return keystrokeDescriptionBuilder.toString();
}
 
Example 20
Source File: SoftKeyboard.java    From AndroidKeyboard with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Use this to monitor key events being delivered to the application.
 * We get first crack at them, and can either resume them or let them
 * continue to the app.
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
            // The InputMethodService already takes care of the back
            // key for us, to dismiss the input method if it is shown.
            // However, our keyboard could be showing a pop-up window
            // that back should dismiss, so we first allow it to do that.
            if (event.getRepeatCount() == 0 && mInputView != null) {
                if (mInputView.handleBack()) {
                    return true;
                }
            }
            break;

        case KeyEvent.KEYCODE_DEL:
            // Special handling of the delete key: if we currently are
            // composing text for the user, we want to modify that instead
            // of let the application to the delete itself.
            if (mComposing.length() > 0) {
                onKey(Keyboard.KEYCODE_DELETE, null);
                return true;
            }
            break;

        case KeyEvent.KEYCODE_ENTER:
            // Let the underlying text editor always handle these.
            return false;

        default:
            // For all other keys, if we want to do transformations on
            // text being entered with a hard keyboard, we need to process
            // it and do the appropriate action.
            if (PROCESS_HARD_KEYS) {
                if (keyCode == KeyEvent.KEYCODE_SPACE
                        && (event.getMetaState() & KeyEvent.META_ALT_ON) != 0) {
                    // A silly example: in our input method, Alt+Space
                    // is a shortcut for 'android' in lower case.
                    InputConnection ic = getCurrentInputConnection();
                    if (ic != null) {
                        // First, tell the editor that it is no longer in the
                        // shift state, since we are consuming this.
                        ic.clearMetaKeyStates(KeyEvent.META_ALT_ON);
                        keyDownUp(KeyEvent.KEYCODE_A);
                        keyDownUp(KeyEvent.KEYCODE_N);
                        keyDownUp(KeyEvent.KEYCODE_D);
                        keyDownUp(KeyEvent.KEYCODE_R);
                        keyDownUp(KeyEvent.KEYCODE_O);
                        keyDownUp(KeyEvent.KEYCODE_I);
                        keyDownUp(KeyEvent.KEYCODE_D);
                        // And we consume this event.
                        return true;
                    }
                }
                if (mPredictionOn && translateKeyDown(keyCode, event)) {
                    return true;
                }
            }
    }

    return super.onKeyDown(keyCode, event);
}