當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.KEYCODE_A屬性代碼示例

本文整理匯總了Java中android.view.KeyEvent.KEYCODE_A屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.KEYCODE_A屬性的具體用法?Java KeyEvent.KEYCODE_A怎麽用?Java KeyEvent.KEYCODE_A使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.KEYCODE_A屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_A:
            startDiscovery();
            break;
        case KeyEvent.KEYCODE_B:
            stopDiscovery();
            break;
        case KeyEvent.KEYCODE_C:
            createBondDiscoveredDevices();
            break;
        case KeyEvent.KEYCODE_D:
            pairBondedDevices();
            break;
        case KeyEvent.KEYCODE_E:
            unpairBondedDevices();
            break;
    }

    return super.onKeyUp(keyCode, event);
}
 
開發者ID:casper-kim,項目名稱:androidthings-bluetooth-pairing,代碼行數:22,代碼來源:MainActivity.java

示例2: onKeyUp

@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,代碼行數:24,代碼來源:MainActivity.java

示例3: onKeyShortcut

@Override
public boolean onKeyShortcut(int keyCode, KeyEvent event) {
    if (event.hasModifiers(KeyEvent.META_CTRL_ON)) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_A:
                if (mState == State.WORKSPACE) {
                    showAppsView(true, false);
                    return true;
                }
                break;
            case KeyEvent.KEYCODE_S: {
                View focusedView = getCurrentFocus();
                if (focusedView instanceof BubbleTextView
                        && focusedView.getTag() instanceof ItemInfo
                        && mAccessibilityDelegate.performAction(focusedView,
                                (ItemInfo) focusedView.getTag(),
                                LauncherAccessibilityDelegate.DEEP_SHORTCUTS)) {
                    PopupContainerWithArrow.getOpen(this).requestFocus();
                    return true;
                }
                break;
            }
            case KeyEvent.KEYCODE_O:
                if (new CustomActionsPopup(this, getCurrentFocus()).show()) {
                    return true;
                }
                break;
        }
    }
    return super.onKeyShortcut(keyCode, event);
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:31,代碼來源:Launcher.java

示例4: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (DLog.DEBUG) {
        Log.w(TAG, "onKeyUp " + event);
    }
    if (handleControlKey(keyCode, event, false)) {
        return true;
    }
    if (event.isCtrlPressed() || mKeyListener.mControlKey.isActive()) {
        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:
            case KeyEvent.KEYCODE_R:
            case KeyEvent.KEYCODE_F:
            case KeyEvent.KEYCODE_L:
                return true;
        }
    } else {
        switch (keyCode) {
            case KeyEvent.KEYCODE_TAB:
                return true;
        }
    }
    return super.onKeyUp(keyCode, event);

}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:31,代碼來源:UndoRedoSupportEditText.java

示例5: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_A) {
        Log.d(TAG, "The button A event was received KEY DOWN");
        displayMode = DisplayMode.TEMPERATURE;
        int[] colors = new int[NUM_LEDS];
        // Switches the rainbow from left to right on each press
        if (rainbowOrder) {
            rainbowOrder = false;
            colors[0] = mRainbow[6];
            colors[1] = mRainbow[5];
            colors[2] = mRainbow[4];
            colors[3] = mRainbow[3];
            colors[4] = mRainbow[2];
            colors[5] = mRainbow[1];
            colors[6] = mRainbow[0];
        } else {
            rainbowOrder = true;
            colors[0] = mRainbow[0];
            colors[1] = mRainbow[1];
            colors[2] = mRainbow[2];
            colors[3] = mRainbow[3];
            colors[4] = mRainbow[4];
            colors[5] = mRainbow[5];
            colors[6] = mRainbow[6];
        }
        soundSpeaker(SOUND_LOW);
        runLedStrip(colors);
        showLED(RED_LED);

        return true;
    }
    return super.onKeyUp(keyCode, event);
}
 
開發者ID:mwolfson,項目名稱:AndroidThings_RainbowHatDemo,代碼行數:34,代碼來源:ThingActivity.java

示例6: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_A) {
        Log.d(TAG, "The button A event was received KEY UP");
        return true;
    }
    return super.onKeyUp(keyCode, event);
}
 
開發者ID:mwolfson,項目名稱:AndroidThings_RainbowHatDemo,代碼行數:8,代碼來源:ThingActivity.java

示例7: keyDown

/**
     * CTRL + C copy z
     * CTRL + V paste z
     * CTRL + B: compile z
     * CTRL + R run z
     * CTRL + X cut z
     * CTRL + Z undo z
     * CTRL + Y redo z
     * CTRL + Q quit
     * CTRL + S save z
     * CTRL + O open z
     * CTRL + F find z
     * CTRL + H find and replace z
     * CTRL + L format code z
     * CTRL + G: goto line z
     */
    public int keyDown(int keyCode, KeyEvent event) {
        if (!mControlKey.isActive()) return -1;
        switch (keyCode) {
            case -99:
            case KEYCODE_CTRL_LEFT:
            case KEYCODE_CTRL_RIGHT:
                mControlKey.onPress();
                return -10;
            case KeyEvent.KEYCODE_A:
                return ACTION_SELECT_ALL;
            case KEYCODE_C:
                return ACTION_COPY;
            case KEYCODE_X:
                return ACTION_CUT;
            case KEYCODE_V:
                return ACTION_PASTE;
            case KEYCODE_B:
                return ACTION_COMPILE;
            case KEYCODE_R:
                return ACTION_RUN;
            case KEYCODE_Z:
                return ACTION_UNDO;
            case KEYCODE_Y:
                return ACTION_REDO;
            case KEYCODE_S:
                return ACTION_SAVE;
            case KEYCODE_O:
                return ACTION_OPEN;
            case KEYCODE_H:
                return ACTION_FIND_AND_REPLACE;
            case KEYCODE_G:
                return ACTION_GOTO_LINE;
            case KEYCODE_L:
                return ACTION_FORMAT_CODE;
            case KEYCODE_F:
                return ACTION_FIND;
        }
        return -1;
//        editText.getEditableText().insert(editText.getSelectionStart(), Character.toString((char) result));
    }
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:56,代碼來源:KeyListener.java

示例8: onKey

@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,代碼行數:62,代碼來源:LModEditor.java

示例9: onKeyDown

@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,代碼行數:42,代碼來源:MainActivity.java


注:本文中的android.view.KeyEvent.KEYCODE_A屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。