Java Code Examples for android.view.KeyEvent#KEYCODE_SHIFT_LEFT

The following examples show how to use android.view.KeyEvent#KEYCODE_SHIFT_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 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 2
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 3
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 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: 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 6
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 7
Source File: KeyboardSelectorWidget.java    From Android-Keyboard with Apache License 2.0 5 votes vote down vote up
private void cancelSelect() {
    if (getCurrentIC() == null) {
        return;
    }
    KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT);
    sendKeyEvent(event);
    mStatus = Status.direct;
    updateSelector();

}
 
Example 8
Source File: KeyboardSelectorWidget.java    From Android-Keyboard with Apache License 2.0 5 votes vote down vote up
private void beginSelect() {
    if (getCurrentIC() == null) {
        return;
    }
    recordSelect();
    if (mStatus != Status.select) {
        cancelSelectWithSelection();
        return;
    }

    KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT);
    sendKeyEvent(event);
}
 
Example 9
Source File: FreeScrollingTextField.java    From CodeEditor with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sendKeyEvent(KeyEvent event) {
    switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_SHIFT_LEFT:
            if (isSelectText())
                selectText(false);
            else
                selectText(true);
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            moveCaretLeft();
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            moveCaretUp();
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            moveCaretRight();
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            moveCaretDown();
            break;
        case KeyEvent.KEYCODE_MOVE_HOME:
            moveCaret(0);
            break;
        case KeyEvent.KEYCODE_MOVE_END:
            moveCaret(_hDoc.length());
            break;
        default:
            return super.sendKeyEvent(event);
    }
    return true;
}
 
Example 10
Source File: FreeScrollingTextField.java    From CodeEditor with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sendKeyEvent(KeyEvent event) {
    switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_SHIFT_LEFT:
            if (isSelectText())
                selectText(false);
            else
                selectText(true);
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            moveCaretLeft();
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            moveCaretUp();
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            moveCaretRight();
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            moveCaretDown();
            break;
        case KeyEvent.KEYCODE_MOVE_HOME:
            moveCaret(0);
            break;
        case KeyEvent.KEYCODE_MOVE_END:
            moveCaret(_hDoc.length());
            break;
        default:
            return super.sendKeyEvent(event);
    }
    return true;
}
 
Example 11
Source File: FreeScrollingTextField.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean sendKeyEvent(KeyEvent event) {
    if(event.getAction()==KeyEvent.ACTION_UP)
        return super.sendKeyEvent(event);
    switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_SHIFT_LEFT:
        case KeyEvent.KEYCODE_SHIFT_RIGHT:
            /*if (isSelectText())
                selectText(false);
            else*/
                selectText(true);
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
              _fieldController.moveCaretLeft(true);
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            _fieldController.moveCaretUp(true);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            _fieldController.moveCaretRight(true);
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            _fieldController.moveCaretDown(true);
            break;
        case KeyEvent.KEYCODE_MOVE_HOME:
            moveCaret(0);
            break;
        case KeyEvent.KEYCODE_MOVE_END:
            moveCaret(_hDoc.length() - 1);
            break;
        default:
            return super.sendKeyEvent(event);
    }
    return true;
}
 
Example 12
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 13
Source File: LatinIME.java    From hackerskeyboard with Apache License 2.0 5 votes vote down vote up
private void sendShiftKey(InputConnection ic, boolean isDown) {
    int key = KeyEvent.KEYCODE_SHIFT_LEFT;
    int meta = KeyEvent.META_SHIFT_ON | KeyEvent.META_SHIFT_LEFT_ON;
    if (isDown) {
        sendKeyDown(ic, key, meta);
    } else {
        sendKeyUp(ic, key, meta);
    }
}
 
Example 14
Source File: ScanGunKeyEventHelper.java    From scangon with Apache License 2.0 5 votes vote down vote up
private void checkLetterStatus(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT || keyCode == KeyEvent.KEYCODE_SHIFT_LEFT) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            //按着shift键,表示大写
            mCaps = true;
        } else {
            //松开shift键,表示小写
            mCaps = false;
        }
    }
}
 
Example 15
Source File: KCWebView.java    From kerkee_android with GNU General Public License v3.0 5 votes vote down vote up
private boolean emulateShiftHeldForWebView(View view)
{
    try
    {
        KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
        shiftPressEvent.dispatch(view, null, null);
        return true;
    }
    catch (Exception e)
    {
        KCLog.e(e);
    }
    return false;
}
 
Example 16
Source File: CanvasActivity.java    From slide-android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event)
{
    if ((keyCode == KeyEvent.KEYCODE_BACK) &&
        (event.getRepeatCount() == 0))
    {
        if (!waiting)
        {
            Toaster.getInstance().showToast("Press back again to close the connection",
                getApplicationContext());

            waiting = true;
            countdown.schedule(
                new TimerTask()
                {
                    @Override
                    public void run()
                    {
                        waiting = false;
                    }
                }, 2000);
        } else
        {
            closeConnection();
        }
        return true;
    } else
    {
        final short[] KEYBOARD = {10000 + 9, 100};
        if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT
            || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT)
        {
            AppSettings.getInstance().getConnectionManager().send(KEYBOARD);
        }
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 17
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;
    }
}