当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.isShiftPressed方法代码示例

本文整理汇总了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);
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:17,代码来源:MainActivity.java

示例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;
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:32,代码来源:SafePswText.java

示例3: zoom

import android.view.KeyEvent; //导入方法依赖的package包/类
public void zoom(KeyEvent event) {
    if (event.isShiftPressed()) {
        mMessageContentView.zoomIn();
    } else {
        mMessageContentView.zoomOut();
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:8,代码来源:MessageContainerView.java

示例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;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:16,代码来源:KeyboardNavigationListener.java

示例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;
}
 
开发者ID:paradoxie,项目名称:DizzyPassword,代码行数:29,代码来源:PswInputView.java

示例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;
}
 
开发者ID:rokudol,项目名称:PswText,代码行数:30,代码来源:PswText.java

示例7: isSwitchPanel

import android.view.KeyEvent; //导入方法依赖的package包/类
public static boolean isSwitchPanel(KeyEvent event){
	return (event.isShiftPressed() &&
				(event.getKeyCode() == KeyEvent.KEYCODE_ENTER));
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:5,代码来源:KeysInterpreter.java

示例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);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:6,代码来源:KeysInterpreter.java

示例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);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:6,代码来源:KeyboardShortcuts.java

示例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;
    }
}
 
开发者ID:Light-Team,项目名称:ModPE-IDE-Source,代码行数:63,代码来源:LModEditor.java

示例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();
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:43,代码来源:HardwareKeyboardEventDecoder.java

示例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;
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:77,代码来源:TerminalView.java


注:本文中的android.view.KeyEvent.isShiftPressed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。