Java Code Examples for android.view.KeyEvent#KEYCODE_ALT_LEFT

The following examples show how to use android.view.KeyEvent#KEYCODE_ALT_LEFT . 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: MetaKeyKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Handles presses of the meta keys.
 */
public boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
        press(content, CAP);
        return true;
    }

    if (keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT
            || keyCode == KeyEvent.KEYCODE_NUM) {
        press(content, ALT);
        return true;
    }

    if (keyCode == KeyEvent.KEYCODE_SYM) {
        press(content, SYM);
        return true;
    }

    return false; // no super to call through to
}
 
Example 2
Source File: MetaKeyKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Handles release of the meta keys.
 */
public boolean onKeyUp(View view, Editable content, int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
        release(content, CAP, event);
        return true;
    }

    if (keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT
            || keyCode == KeyEvent.KEYCODE_NUM) {
        release(content, ALT, event);
        return true;
    }

    if (keyCode == KeyEvent.KEYCODE_SYM) {
        release(content, SYM, event);
        return true;
    }

    return false; // no super to call through to
}
 
Example 3
Source File: MetaKeyKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Handles presses of the meta keys.
 */
public static long handleKeyDown(long state, int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
        return press(state, META_SHIFT_ON, META_SHIFT_MASK,
                META_CAP_LOCKED, META_CAP_PRESSED, META_CAP_RELEASED, META_CAP_USED);
    }

    if (keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT
            || keyCode == KeyEvent.KEYCODE_NUM) {
        return press(state, META_ALT_ON, META_ALT_MASK,
                META_ALT_LOCKED, META_ALT_PRESSED, META_ALT_RELEASED, META_ALT_USED);
    }

    if (keyCode == KeyEvent.KEYCODE_SYM) {
        return press(state, META_SYM_ON, META_SYM_MASK,
                META_SYM_LOCKED, META_SYM_PRESSED, META_SYM_RELEASED, META_SYM_USED);
    }
    return state;
}
 
Example 4
Source File: MetaKeyKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Handles release of the meta keys.
 */
public static long handleKeyUp(long state, int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
        return release(state, META_SHIFT_ON, META_SHIFT_MASK,
                META_CAP_PRESSED, META_CAP_RELEASED, META_CAP_USED, event);
    }

    if (keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT
            || keyCode == KeyEvent.KEYCODE_NUM) {
        return release(state, META_ALT_ON, META_ALT_MASK,
                META_ALT_PRESSED, META_ALT_RELEASED, META_ALT_USED, event);
    }

    if (keyCode == KeyEvent.KEYCODE_SYM) {
        return release(state, META_SYM_ON, META_SYM_MASK,
                META_SYM_PRESSED, META_SYM_RELEASED, META_SYM_USED, event);
    }
    return state;
}
 
Example 5
Source File: KeyComboModelApp.java    From talkback with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isEligibleKeyComboCode(long keyComboCode) {
  if (keyComboCode == KEY_COMBO_CODE_UNASSIGNED) {
    return true;
  }

  int modifier = KeyComboManager.getModifier(keyComboCode);
  if ((modifier & REQUIRED_MODIFIER_MASK) == 0
      || (modifier | ELIGIBLE_MODIFIER_MASK) != ELIGIBLE_MODIFIER_MASK) {
    return false;
  }

  int keyCode = KeyComboManager.getKeyCode(keyComboCode);
  return keyCode != 0
      && keyCode != KeyEvent.KEYCODE_SHIFT_LEFT
      && keyCode != KeyEvent.KEYCODE_SHIFT_RIGHT
      && keyCode != KeyEvent.KEYCODE_ALT_LEFT
      && keyCode != KeyEvent.KEYCODE_ALT_RIGHT
      && keyCode != KeyEvent.KEYCODE_CTRL_LEFT
      && keyCode != KeyEvent.KEYCODE_CTRL_RIGHT;
}
 
Example 6
Source File: CreditEntryFieldBase.java    From CreditCardEntry with MIT License 6 votes vote down vote up
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
	if (event.getAction() == KeyEvent.ACTION_DOWN)
		return false;
	if (keyCode == KeyEvent.KEYCODE_ALT_LEFT
			|| keyCode == KeyEvent.KEYCODE_ALT_RIGHT
			|| keyCode == KeyEvent.KEYCODE_SHIFT_LEFT
			|| keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT)
		return false;

	if (keyCode == KeyEvent.KEYCODE_DEL
			&& this.getText().toString().length() == 0) {
		if (delegate != null) {
			delegate.focusOnPreviousField(this);
		}
	}
	return false;
}
 
Example 7
Source File: InputConnectionHacker.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sendKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
        isShiftPressed = event.getAction() == KeyEvent.ACTION_DOWN;
    } else if (keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT
            || keyCode == KeyEvent.KEYCODE_NUM) {
        isAltPressed = event.getAction() == KeyEvent.ACTION_DOWN;
    } else if (keyCode == KeyEvent.KEYCODE_SYM) {
        isSymPressed = event.getAction() == KeyEvent.ACTION_DOWN;
    } else if (keyCode == KeyEvent.KEYCODE_CTRL_LEFT || keyCode == KeyEvent.KEYCODE_CTRL_RIGHT) {
        isCtrlPressed = event.getAction() == KeyEvent.ACTION_DOWN;
    }
    return ic.sendKeyEvent(event);
}
 
Example 8
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 9
Source File: EmulatorView.java    From Ansole with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
    if (sTrapAltAndMeta) {
        boolean altEsc = mKeyListener.getAltSendsEsc();
        boolean altOn = (event.getMetaState() & KeyEvent.META_ALT_ON) != 0;
        boolean metaOn = (event.getMetaState() & KeyEvent.META_META_ON) != 0;
        boolean altPressed = (keyCode == KeyEvent.KEYCODE_ALT_LEFT)
                || (keyCode == KeyEvent.KEYCODE_ALT_RIGHT);
        boolean altActive = mKeyListener.isAltActive();
        if (altEsc && (altOn || altPressed || altActive || metaOn)) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                return onKeyDown(keyCode, event);
            } else {
                return onKeyUp(keyCode, event);
            }
        }
    }

    if (handleHardwareControlKey(keyCode, event)) {
        return true;
    }

    if (mKeyListener.isCtrlActive()) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            return onKeyDown(keyCode, event);
        } else {
            return onKeyUp(keyCode, event);
        }
    }

    return super.onKeyPreIme(keyCode, event);
}
 
Example 10
Source File: TermKeyListener.java    From Ansole with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handle a keyUp event.
 *
 * @param keyCode the keyCode of the keyUp event
 */
public void keyUp(int keyCode, KeyEvent event) {
    boolean allowToggle = isEventFromToggleDevice(event);
    switch (keyCode) {
    case KeyEvent.KEYCODE_ALT_LEFT:
    case KeyEvent.KEYCODE_ALT_RIGHT:
        if (allowToggle) {
            mAltKey.onRelease();
            updateCursorMode();
        }
        break;
    case KeyEvent.KEYCODE_SHIFT_LEFT:
    case KeyEvent.KEYCODE_SHIFT_RIGHT:
        if (allowToggle) {
            mCapKey.onRelease();
            updateCursorMode();
        }
        break;

    case KEYCODE_CTRL_LEFT:
    case KEYCODE_CTRL_RIGHT:
        // ignore control keys.
        break;

    default:
        // Ignore other keyUps
        break;
    }
}