本文整理汇总了Java中android.view.KeyEvent.isShiftPressed方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.isShiftPressed方法的具体用法?Java KeyEvent.isShiftPressed怎么用?Java KeyEvent.isShiftPressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.isShiftPressed方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchKeyEvent
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN && event.isCtrlPressed()) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_P:
// Open a new private window
if(event.isShiftPressed()) {
startActivity(new Intent(this, IncognitoActivity.class));
overridePendingTransition(R.anim.slide_up_in, R.anim.fade_out_scale);
return true;
}
break;
}
}
return super.dispatchKeyEvent(event);
}
示例2: onKey
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (event.isShiftPressed()) {// Handle * # and other keys
return false;
}
if (keyCode >= KeyEvent.KEYCODE_0
&& keyCode <= KeyEvent.KEYCODE_9) {// Only deal with
// numbers
if (result.size() < pswLength) {
result.add(keyCode - 7);
invalidate();
ensureFinishInput();
}
return true;
}
if (keyCode == KeyEvent.KEYCODE_DEL) {
if (!result.isEmpty()) {// Not empty, delete the last one
saveResult = result.size();
result.remove(result.size() - 1);
invalidate();
}
return true;
}
if (keyCode == KeyEvent.KEYCODE_ENTER) {
ensureFinishInput();
return true;
}
}
return false;
}
示例3: zoom
import android.view.KeyEvent; //导入方法依赖的package包/类
public void zoom(KeyEvent event) {
if (event.isShiftPressed()) {
mMessageContentView.zoomIn();
} else {
mMessageContentView.zoomOut();
}
}
示例4: onKey
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_TAB && event.getAction() == KeyEvent.ACTION_DOWN) {
if (event.hasNoModifiers()) {
View forward = getNextFocusForward();
if (forward != null) return forward.requestFocus();
} else if (event.isShiftPressed()) {
View backward = getNextFocusBackward();
if (backward != null) return backward.requestFocus();
}
} else if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
return handleEnterKeyPress();
}
return false;
}
示例5: onKey
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (event.isShiftPressed()) {//处理*#等键
return false;
}
if (keyCode >= KeyEvent.KEYCODE_0 && keyCode <= KeyEvent.KEYCODE_9) {//只处理数字
if (result.size() < count) {
result.add(keyCode - 7);
invalidate();
ensureFinishInput();
}
return true;
}
if (keyCode == KeyEvent.KEYCODE_DEL) {
if (!result.isEmpty()) {//不为空,删除最后一个
result.remove(result.size() - 1);
invalidate();
}
return true;
}
if (keyCode == KeyEvent.KEYCODE_ENTER) {
ensureFinishInput();
return true;
}
}
return false;
}
示例6: onKey
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (event.isShiftPressed()) {//处理*#等键
return false;
}
if (keyCode >= KeyEvent.KEYCODE_0 && keyCode <= KeyEvent.KEYCODE_9) {//只处理数字
if (result.size() < pswLength) {
result.add(keyCode - 7);
invalidate();
FinishInput();
}
return true;
}
if (keyCode == KeyEvent.KEYCODE_DEL) {
if (!result.isEmpty()) {//不为空时,删除最后一个数字
saveResult = result.size();
result.remove(result.size() - 1);
invalidate();
}
return true;
}
if (keyCode == KeyEvent.KEYCODE_ENTER) {
FinishInput();
return true;
}
}
return false;
}
示例7: isSwitchPanel
import android.view.KeyEvent; //导入方法依赖的package包/类
public static boolean isSwitchPanel(KeyEvent event){
return (event.isShiftPressed() &&
(event.getKeyCode() == KeyEvent.KEYCODE_ENTER));
}
示例8: isTab
import android.view.KeyEvent; //导入方法依赖的package包/类
private static boolean isTab(KeyEvent event){
return (event.isShiftPressed() &&
(event.getKeyCode() == KeyEvent.KEYCODE_SPACE)) ||
(event.getKeyCode() == KeyEvent.KEYCODE_TAB);
}
示例9: getMetaState
import android.view.KeyEvent; //导入方法依赖的package包/类
private static int getMetaState(KeyEvent event) {
return (event.isCtrlPressed() ? CTRL : 0)
| (event.isAltPressed() ? ALT : 0)
| (event.isShiftPressed() ? SHIFT : 0);
}
示例10: onKey
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(event.getAction() == 0 && event.isCtrlPressed()
&& !event.isShiftPressed()
&& !event.isAltPressed()
&& !event.isFunctionPressed()
&& keyCode == KeyEvent.KEYCODE_X) {
cut(); //Ctrl+X
return true;
} else if(event.getAction() == 0 && event.isCtrlPressed()
&& !event.isShiftPressed()
&& !event.isAltPressed()
&& !event.isFunctionPressed()
&& keyCode == KeyEvent.KEYCODE_C) {
copy(); //Ctrl-C
return true;
} else if(event.getAction() == 0 && event.isCtrlPressed()
&& !event.isShiftPressed()
&& !event.isAltPressed()
&& !event.isFunctionPressed()
&& keyCode == KeyEvent.KEYCODE_V) {
paste(); //Ctrl-V
return true;
} else if(event.getAction() == 0 && event.isCtrlPressed()
&& !event.isShiftPressed()
&& !event.isAltPressed()
&& !event.isFunctionPressed()
&& keyCode == KeyEvent.KEYCODE_Z) {
undo(); //Ctrl-Z
return true;
} else if(event.getAction() == 0 && event.isCtrlPressed()
&& !event.isShiftPressed()
&& !event.isAltPressed()
&& !event.isFunctionPressed()
&& keyCode == KeyEvent.KEYCODE_Y) {
redo(); //Ctrl-Y
return true;
} else if(event.getAction() == 0 && event.isCtrlPressed()
&& !event.isShiftPressed()
&& !event.isAltPressed()
&& !event.isFunctionPressed()
&& keyCode == KeyEvent.KEYCODE_A) {
selectAll(); //Ctrl-A
return true;
} else if(event.getAction() == 0 && event.isCtrlPressed()
&& event.isShiftPressed()
&& !event.isAltPressed()
&& !event.isFunctionPressed()
&& keyCode == KeyEvent.KEYCODE_D) {
deleteLine(); //Ctrl+Shift-D
return true;
} else if(event.getAction() == 0 && event.isCtrlPressed()
&& !event.isShiftPressed()
&& event.isAltPressed()
&& !event.isFunctionPressed()
&& keyCode == KeyEvent.KEYCODE_A) {
selectLine(); //Ctrl+Alt-A
return true;
} else {
return false;
}
}
示例11: decodeHardwareKey
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public Event decodeHardwareKey(final KeyEvent keyEvent) {
// KeyEvent#getUnicodeChar() does not exactly returns a unicode char, but rather a value
// that includes both the unicode char in the lower 21 bits and flags in the upper bits,
// hence the name "codePointAndFlags". {@see KeyEvent#getUnicodeChar()} for more info.
final int codePointAndFlags = keyEvent.getUnicodeChar();
// The keyCode is the abstraction used by the KeyEvent to represent different keys that
// do not necessarily map to a unicode character. This represents a physical key, like
// the key for 'A' or Space, but also Backspace or Ctrl or Caps Lock.
final int keyCode = keyEvent.getKeyCode();
final boolean isKeyRepeat = (0 != keyEvent.getRepeatCount());
if (KeyEvent.KEYCODE_DEL == keyCode) {
return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT, Constants.CODE_DELETE,
null /* next */, isKeyRepeat);
}
if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode
|| KeyEvent.KEYCODE_ENTER == keyCode) {
if (0 != (codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT)) {
// A dead key.
return Event.createDeadEvent(
codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK, keyCode,
null /* next */);
}
if (KeyEvent.KEYCODE_ENTER == keyCode) {
// The Enter key. If the Shift key is not being pressed, this should send a
// CODE_ENTER to trigger the action if any, or a carriage return otherwise. If the
// Shift key is being pressed, this should send a CODE_SHIFT_ENTER and let
// Latin IME decide what to do with it.
if (keyEvent.isShiftPressed()) {
return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT,
Constants.CODE_SHIFT_ENTER, null /* next */, isKeyRepeat);
}
return Event.createHardwareKeypressEvent(Constants.CODE_ENTER, keyCode,
null /* next */, isKeyRepeat);
}
// If not Enter, then this is just a regular keypress event for a normal character
// that can be committed right away, taking into account the current state.
return Event.createHardwareKeypressEvent(codePointAndFlags, keyCode, null /* next */,
isKeyRepeat);
}
return Event.createNotHandledEvent();
}
示例12: onKeyDown
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (LOG_KEY_EVENTS)
Log.i(EmulatorDebug.LOG_TAG, "onKeyDown(keyCode=" + keyCode + ", isSystem()=" + event.isSystem() + ", event=" + event + ")");
if (mEmulator == null) return true;
if (mClient.onKeyDown(keyCode, event, mTermSession)) {
invalidate();
return true;
} else if (event.isSystem() && (!mClient.shouldBackButtonBeMappedToEscape() || keyCode != KeyEvent.KEYCODE_BACK)) {
return super.onKeyDown(keyCode, event);
} else if (event.getAction() == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
mTermSession.write(event.getCharacters());
return true;
}
final int metaState = event.getMetaState();
final boolean controlDownFromEvent = event.isCtrlPressed();
final boolean leftAltDownFromEvent = (metaState & KeyEvent.META_ALT_LEFT_ON) != 0;
final boolean rightAltDownFromEvent = (metaState & KeyEvent.META_ALT_RIGHT_ON) != 0;
int keyMod = 0;
if (controlDownFromEvent) keyMod |= KeyHandler.KEYMOD_CTRL;
if (event.isAltPressed()) keyMod |= KeyHandler.KEYMOD_ALT;
if (event.isShiftPressed()) keyMod |= KeyHandler.KEYMOD_SHIFT;
if (handleKeyCode(keyCode, keyMod)) {
if (LOG_KEY_EVENTS) Log.i(EmulatorDebug.LOG_TAG, "handleKeyCode() took key event");
return true;
}
// Clear Ctrl since we handle that ourselves:
int bitsToClear = KeyEvent.META_CTRL_MASK;
if (rightAltDownFromEvent) {
// Let right Alt/Alt Gr be used to compose characters.
} else {
// Use left alt to send to terminal (e.g. Left Alt+B to jump back a word), so remove:
bitsToClear |= KeyEvent.META_ALT_ON | KeyEvent.META_ALT_LEFT_ON;
}
int effectiveMetaState = event.getMetaState() & ~bitsToClear;
int result = event.getUnicodeChar(effectiveMetaState);
if (LOG_KEY_EVENTS)
Log.i(EmulatorDebug.LOG_TAG, "KeyEvent#getUnicodeChar(" + effectiveMetaState + ") returned: " + result);
if (result == 0) {
return true;
}
int oldCombiningAccent = mCombiningAccent;
if ((result & KeyCharacterMap.COMBINING_ACCENT) != 0) {
// If entered combining accent previously, write it out:
if (mCombiningAccent != 0)
inputCodePoint(mCombiningAccent, controlDownFromEvent, leftAltDownFromEvent);
mCombiningAccent = result & KeyCharacterMap.COMBINING_ACCENT_MASK;
} else {
if (mCombiningAccent != 0) {
int combinedChar = KeyCharacterMap.getDeadChar(mCombiningAccent, result);
if (combinedChar > 0) result = combinedChar;
mCombiningAccent = 0;
}
inputCodePoint(result, controlDownFromEvent, leftAltDownFromEvent);
}
if (mCombiningAccent != oldCombiningAccent) invalidate();
if (onAutoCompleteListener != null) {
if (event.isPrintingKey()) {
char printingChar = (char) event.getUnicodeChar(metaState);
if (printingChar != '\b') {
// ASCII chars
onAutoCompleteListener.onCompletionRequired(new String(new char[]{printingChar}));
}
}
}
return true;
}