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


Java KeyEvent.isCtrlPressed方法代码示例

本文整理汇总了Java中android.view.KeyEvent.isCtrlPressed方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.isCtrlPressed方法的具体用法?Java KeyEvent.isCtrlPressed怎么用?Java KeyEvent.isCtrlPressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.isCtrlPressed方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onKeyUp

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
    if (event.isCtrlPressed()) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_A:
            case KeyEvent.KEYCODE_X:
            case KeyEvent.KEYCODE_C:
            case KeyEvent.KEYCODE_V:
            case KeyEvent.KEYCODE_Z:
            case KeyEvent.KEYCODE_Y:
            case KeyEvent.KEYCODE_S:
                return true;
            default:
                return false;
        }
    } else {
        switch (keyCode) {
            case KeyEvent.KEYCODE_TAB:
                return true;
            default:
                return false;
        }
    }
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:25,代码来源:MainActivity.java

示例2: onKeyShortcut

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyShortcut(int keyCode, KeyEvent event) {
    if (event.isCtrlPressed()) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_R:
                saveAndRun();
                break;

            case KeyEvent.KEYCODE_S:
                save();
                break;

            case KeyEvent.KEYCODE_F:
                toggleApiDrawer();

                break;
        }
    }
    return super.onKeyShortcut(keyCode, event);
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:21,代码来源:EditorActivity.java

示例3: 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

示例4: dispatchKeyEvent

import android.view.KeyEvent; //导入方法依赖的package包/类
/**
 * Called to process key events.  You can override this to intercept all
 * key events before they are dispatched to the window.  Be sure to call
 * this implementation for key events that should be handled normally.
 *
 * @param event The key event.
 *
 * @return boolean Return true if this event was consumed.
 */
public boolean dispatchKeyEvent(KeyEvent event) {
    onUserInteraction();

    // Let action bars open menus in response to the menu key prioritized over
    // the window handling it
    final int keyCode = event.getKeyCode();
    if (keyCode == KeyEvent.KEYCODE_MENU &&
            mActionBar != null && mActionBar.onMenuKeyEvent(event)) {
        return true;
    } else if (event.isCtrlPressed() &&
            event.getUnicodeChar(event.getMetaState() & ~KeyEvent.META_CTRL_MASK) == '<') {
        // Capture the Control-< and send focus to the ActionBar
        final int action = event.getAction();
        if (action == KeyEvent.ACTION_DOWN) {
            final ActionBar actionBar = getActionBar();
            if (actionBar != null && actionBar.isShowing() && actionBar.requestFocus()) {
                mEatKeyUpEvent = true;
                return true;
            }
        } else if (action == KeyEvent.ACTION_UP && mEatKeyUpEvent) {
            mEatKeyUpEvent = false;
            return true;
        }
    }

    Window win = getWindow();
    if (win.superDispatchKeyEvent(event)) {
        return true;
    }
    View decor = mDecor;
    if (decor == null) decor = win.getDecorView();
    return event.dispatch(this, decor != null
            ? decor.getKeyDispatcherState() : null, this);
}
 
开发者ID:JessYanCoding,项目名称:ProgressManager,代码行数:44,代码来源:a.java

示例5: onKeyShortcut

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyShortcut(int keyCode, KeyEvent event) {
    if (event.isCtrlPressed()) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_R:
                finish();
                break;
        }
    }
    return super.onKeyShortcut(keyCode, event);
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:12,代码来源:AppRunnerActivity.java

示例6: onKeyDown

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_F3
            || (keyCode == KeyEvent.KEYCODE_G && event.isCtrlPressed())) {
        mFindToolbar.hideKeyboardAndStartFinding(!event.isShiftPressed());
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:FindToolbar.java

示例7: onKeyDown

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    switch (keyCode) {
        case KeyEvent.KEYCODE_R:
            mViewModel.addRectLayer();
            return true;
        case KeyEvent.KEYCODE_T:
            mViewModel.addTriangleLayer();
            return true;
        case KeyEvent.KEYCODE_O:
            mViewModel.addOvalLayer();
            return true;
    }

    if (mBinding.documentView.hasFocus()) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_DEL:
            case KeyEvent.KEYCODE_FORWARD_DEL:
                return onContextMenuAction(DELETE);
        }

        if (event.isCtrlPressed()) {
            switch (keyCode) {
                case KeyEvent.KEYCODE_X:
                    return onContextMenuAction(CUT);
                case KeyEvent.KEYCODE_C:
                    return onContextMenuAction(COPY);
                case KeyEvent.KEYCODE_V:
                    return onContextMenuAction(PASTE);
                case KeyEvent.KEYCODE_D:
                    return onContextMenuAction(DUPLICATE);
                case KeyEvent.KEYCODE_G:
                    return onContextMenuAction(GROUP);
            }
        }
    }

    return super.onKeyDown(keyCode, event);
}
 
开发者ID:google,项目名称:spline,代码行数:41,代码来源:EditorActivity.java

示例8: onKeyDown

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {

    if (event.isCtrlPressed()) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_A:
                return onTextContextMenuItem(ID_SELECT_ALL);
            case KeyEvent.KEYCODE_X:
                return onTextContextMenuItem(ID_CUT);
            case KeyEvent.KEYCODE_C:
                return onTextContextMenuItem(ID_COPY);
            case KeyEvent.KEYCODE_V:
                return onTextContextMenuItem(ID_PASTE);
            case KeyEvent.KEYCODE_Z:
                if (getCanUndo()) {
                    return onTextContextMenuItem(ID_UNDO);
                }
            case KeyEvent.KEYCODE_Y:
                if (getCanRedo()) {
                    return onTextContextMenuItem(ID_REDO);
                }
            case KeyEvent.KEYCODE_S:
                ((MainActivity) getContext()).saveTheFile(false);
                return true;
            default:
                return super.onKeyDown(keyCode, event);
        }
    } else {
        switch (keyCode) {
            case KeyEvent.KEYCODE_TAB:
                String textToInsert = "  ";
                int start, end;
                start = Math.max(getSelectionStart(), 0);
                end = Math.max(getSelectionEnd(), 0);
                getText().replace(Math.min(start, end), Math.max(start, end),
                        textToInsert, 0, textToInsert.length());
                return true;
            default:
                return super.onKeyDown(keyCode, event);
        }
    }
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:43,代码来源:MainActivity.java

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