Example usage for android.view KeyEvent KEYCODE_I

List of usage examples for android.view KeyEvent KEYCODE_I

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_I.

Prototype

int KEYCODE_I

To view the source code for android.view KeyEvent KEYCODE_I.

Click Source Link

Document

Key code constant: 'I' key.

Usage

From source file:Main.java

public static int lookupKeycode(boolean shiftDown, int keycode) {
    switch (keycode) {
    // case KeyEvent.KEYCODE_SHIFT_LEFT: return 0x00;
    // case KeyEvent.KEYCODE_SHIFT_RIGHT: return 0x00;
    case KeyEvent.KEYCODE_0:
        return shiftDown ? 0x126 : 0x27;
    case KeyEvent.KEYCODE_1:
        return 0x30;
    case KeyEvent.KEYCODE_2:
        return 0x31;
    case KeyEvent.KEYCODE_3:
        return 0x11;
    case KeyEvent.KEYCODE_4:
        return 0x12;
    case KeyEvent.KEYCODE_5:
        return 0x13;
    case KeyEvent.KEYCODE_6:
        return 0x34;
    case KeyEvent.KEYCODE_7:
        return shiftDown ? 0x134 : 0x24;
    case KeyEvent.KEYCODE_8:
        return 0x15;
    case KeyEvent.KEYCODE_9:
        return shiftDown ? 0x115 : 0x26;
    case KeyEvent.KEYCODE_A:
        return 0x41;
    case KeyEvent.KEYCODE_B:
        return 0x64;
    case KeyEvent.KEYCODE_C:
        return 0x52;
    case KeyEvent.KEYCODE_D:
        return 0x32;
    case KeyEvent.KEYCODE_E:
        return 0x22;
    case KeyEvent.KEYCODE_F:
        return 0x43;
    case KeyEvent.KEYCODE_G:
        return 0x53;
    case KeyEvent.KEYCODE_H:
        return 0x54;
    case KeyEvent.KEYCODE_I:
        return 0x25;
    case KeyEvent.KEYCODE_J:
        return 0x45;
    case KeyEvent.KEYCODE_K:
        return 0x46;
    case KeyEvent.KEYCODE_L:
        return 0x56;
    case KeyEvent.KEYCODE_M:
        return 0x65;
    case KeyEvent.KEYCODE_N:
        return 0x55;
    case KeyEvent.KEYCODE_O:
        return 0x36;
    case KeyEvent.KEYCODE_P:
        return 0x37;
    case KeyEvent.KEYCODE_Q:
        return 0x10;
    case KeyEvent.KEYCODE_R:
        return 0x33;
    case KeyEvent.KEYCODE_S:
        return 0x51;
    case KeyEvent.KEYCODE_T:
        return 0x23;
    case KeyEvent.KEYCODE_U:
        return 0x35;
    case KeyEvent.KEYCODE_V:
        return 0x63;
    case KeyEvent.KEYCODE_W:
        return 0x21;
    case KeyEvent.KEYCODE_X:
        return 0x42;
    case KeyEvent.KEYCODE_Y:
        return 0x44;
    case KeyEvent.KEYCODE_Z:
        return 0x61;
    case KeyEvent.KEYCODE_SPACE:
        return 0x62;
    case KeyEvent.KEYCODE_ENTER:
        return 0x49;
    case KeyEvent.KEYCODE_DEL:
        return 0x59;
    case KeyEvent.KEYCODE_APOSTROPHE:
        return shiftDown ? 0x31 : 0x124;
    case KeyEvent.KEYCODE_POUND:
        return 0x111; // '#' is Shift+3
    case KeyEvent.KEYCODE_MINUS:
        return shiftDown ? 0x238 : 0x17;
    case KeyEvent.KEYCODE_EQUALS:
        return 0x117;
    case KeyEvent.KEYCODE_AT:
        return 0x47;
    case KeyEvent.KEYCODE_STAR:
        return 0x148;
    case KeyEvent.KEYCODE_PERIOD:
        return shiftDown ? 0x248 : 0x67;
    case KeyEvent.KEYCODE_SEMICOLON:
        return 0x57;
    case KeyEvent.KEYCODE_SLASH:
        return 0x68;
    case KeyEvent.KEYCODE_PLUS:
        return 0x157;
    case KeyEvent.KEYCODE_COMMA:
        return 0x66;
    // case KeyEvent.KEYCODE_GRAVE: return 0x??;
    // case KeyEvent.KEYCODE_LEFT_BRACKET: return 0x??;
    // case KeyEvent.KEYCODE_RIGHT_BRACKET: return 0x??;
    }//  w  ww. j  av a2s  .  c o  m
    return 0xaa;
}

From source file:Main.java

public static String getChar(int keyCode) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_0:
        return "0";
    case KeyEvent.KEYCODE_1:
        return "1";
    case KeyEvent.KEYCODE_2:
        return "2";
    case KeyEvent.KEYCODE_3:
        return "3";
    case KeyEvent.KEYCODE_4:
        return "4";
    case KeyEvent.KEYCODE_5:
        return "5";
    case KeyEvent.KEYCODE_6:
        return "6";
    case KeyEvent.KEYCODE_7:
        return "7";
    case KeyEvent.KEYCODE_8:
        return "8";
    case KeyEvent.KEYCODE_9:
        return "9";
    case KeyEvent.KEYCODE_A:
        return "a";
    case KeyEvent.KEYCODE_B:
        return "b";
    case KeyEvent.KEYCODE_C:
        return "c";
    case KeyEvent.KEYCODE_D:
        return "d";
    case KeyEvent.KEYCODE_E:
        return "e";
    case KeyEvent.KEYCODE_F:
        return "f";
    case KeyEvent.KEYCODE_G:
        return "g";
    case KeyEvent.KEYCODE_H:
        return "h";
    case KeyEvent.KEYCODE_I:
        return "i";
    case KeyEvent.KEYCODE_J:
        return "j";
    case KeyEvent.KEYCODE_K:
        return "k";
    case KeyEvent.KEYCODE_L:
        return "l";
    case KeyEvent.KEYCODE_M:
        return "m";
    case KeyEvent.KEYCODE_N:
        return "n";
    case KeyEvent.KEYCODE_O:
        return "o";
    case KeyEvent.KEYCODE_P:
        return "p";
    case KeyEvent.KEYCODE_Q:
        return "q";
    case KeyEvent.KEYCODE_R:
        return "r";
    case KeyEvent.KEYCODE_S:
        return "s";
    case KeyEvent.KEYCODE_T:
        return "t";
    case KeyEvent.KEYCODE_U:
        return "u";
    case KeyEvent.KEYCODE_V:
        return "v";
    case KeyEvent.KEYCODE_W:
        return "w";
    case KeyEvent.KEYCODE_X:
        return "x";
    case KeyEvent.KEYCODE_Y:
        return "y";
    case KeyEvent.KEYCODE_Z:
        return "z";
    case KeyEvent.KEYCODE_DEL:
        return "{BKSP}";
    case KeyEvent.KEYCODE_ENTER:
    case KeyEvent.KEYCODE_DPAD_CENTER:
        return "{ENTER}";
    case KeyEvent.KEYCODE_SPACE:
        return " ";
    case KeyEvent.KEYCODE_DPAD_DOWN:
        return "{DOWN}";
    case KeyEvent.KEYCODE_DPAD_UP:
        return "{UP}";
    case KeyEvent.KEYCODE_DPAD_LEFT:
        return "{LEFT}";
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        return "{RIGHT}";
    }// w  w w.j  a va 2s .  c  om
    return null;
}

From source file:Main.java

public static String getKeyNameByCode(int code) {
    switch (code) {
    case KeyEvent.KEYCODE_0:
        return "<0>";
    case KeyEvent.KEYCODE_1:
        return "<1>";
    case KeyEvent.KEYCODE_2:
        return "<2>";
    case KeyEvent.KEYCODE_3:
        return "<3>";
    case KeyEvent.KEYCODE_4:
        return "<4>";
    case KeyEvent.KEYCODE_5:
        return "<5>";
    case KeyEvent.KEYCODE_6:
        return "<6>";
    case KeyEvent.KEYCODE_7:
        return "<7>";
    case KeyEvent.KEYCODE_8:
        return "<8>";
    case KeyEvent.KEYCODE_9:
        return "<9>";
    case KeyEvent.KEYCODE_A:
        return "<A>";
    case KeyEvent.KEYCODE_B:
        return "<B>";
    case KeyEvent.KEYCODE_C:
        return "<C>";
    case KeyEvent.KEYCODE_D:
        return "<D>";
    case KeyEvent.KEYCODE_E:
        return "<E>";
    case KeyEvent.KEYCODE_F:
        return "<F>";
    case KeyEvent.KEYCODE_G:
        return "<G>";
    case KeyEvent.KEYCODE_H:
        return "<H>";
    case KeyEvent.KEYCODE_I:
        return "<I>";
    case KeyEvent.KEYCODE_J:
        return "<J>";
    case KeyEvent.KEYCODE_K:
        return "<K>";
    case KeyEvent.KEYCODE_L:
        return "<L>";
    case KeyEvent.KEYCODE_M:
        return "<M>";
    case KeyEvent.KEYCODE_N:
        return "<N>";
    case KeyEvent.KEYCODE_O:
        return "<O>";
    case KeyEvent.KEYCODE_P:
        return "<P>";
    case KeyEvent.KEYCODE_Q:
        return "<Q>";
    case KeyEvent.KEYCODE_R:
        return "<R>";
    case KeyEvent.KEYCODE_S:
        return "<S>";
    case KeyEvent.KEYCODE_T:
        return "<T>";
    case KeyEvent.KEYCODE_U:
        return "<U>";
    case KeyEvent.KEYCODE_V:
        return "<V>";
    case KeyEvent.KEYCODE_W:
        return "<W>";
    case KeyEvent.KEYCODE_X:
        return "<X>";
    case KeyEvent.KEYCODE_Y:
        return "<Y>";
    case KeyEvent.KEYCODE_Z:
        return "<Z>";
    case KeyEvent.KEYCODE_APOSTROPHE:
        return "<'>";
    case KeyEvent.KEYCODE_AT:
        return "<@>";
    case KeyEvent.KEYCODE_BACK:
        return "<Back>";
    case KeyEvent.KEYCODE_BACKSLASH:
        return "<\\>";
    case KeyEvent.KEYCODE_CALL:
        return "<Call>";
    case KeyEvent.KEYCODE_CAMERA:
        return "<Camera>";
    case KeyEvent.KEYCODE_CLEAR:
        return "<Clear>";
    case KeyEvent.KEYCODE_COMMA:
        return "<,>";
    case KeyEvent.KEYCODE_DEL:
        return "<Del>";
    case KeyEvent.KEYCODE_DPAD_CENTER:
        return "<PadCenter>";
    case KeyEvent.KEYCODE_DPAD_DOWN:
        return "<PadDown>";
    case KeyEvent.KEYCODE_DPAD_LEFT:
        return "<PadLeft>";
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        return "<PadRight>";
    case KeyEvent.KEYCODE_DPAD_UP:
        return "<PadUp>";
    case KeyEvent.KEYCODE_ENDCALL:
        return "<EndCall>";
    case KeyEvent.KEYCODE_ENTER:
        return "<Enter>";
    case KeyEvent.KEYCODE_ENVELOPE:
        return "<Envelope>";
    case KeyEvent.KEYCODE_EQUALS:
        return "<=>";
    case KeyEvent.KEYCODE_EXPLORER:
        return "<Explorer>";
    case KeyEvent.KEYCODE_FOCUS:
        return "<??? 0>";
    case KeyEvent.KEYCODE_GRAVE:
        return "<??? 1>";
    case KeyEvent.KEYCODE_HEADSETHOOK:
        return "<??? 2>";
    case KeyEvent.KEYCODE_HOME:
        return "<Home>";
    case KeyEvent.KEYCODE_LEFT_BRACKET:
        return "<(>";
    case KeyEvent.KEYCODE_MENU:
        return "<Menu>";
    case KeyEvent.KEYCODE_MINUS:
        return "<->";
    case KeyEvent.KEYCODE_NOTIFICATION:
        return "<??? 3>";
    case KeyEvent.KEYCODE_NUM:
        return "<Num>";
    case KeyEvent.KEYCODE_PERIOD:
        return "<??? 4>";
    case KeyEvent.KEYCODE_PLUS:
        return "<+>";
    case KeyEvent.KEYCODE_POUND:
        return "<??? 5>";
    case KeyEvent.KEYCODE_POWER:
        return "<Power>";
    case KeyEvent.KEYCODE_RIGHT_BRACKET:
        return "<)>";
    case KeyEvent.KEYCODE_SEMICOLON:
        return "<;>";
    case KeyEvent.KEYCODE_SLASH:
        return "</>";
    case KeyEvent.KEYCODE_SOFT_LEFT:
        return "<??? 6>";
    case KeyEvent.KEYCODE_SOFT_RIGHT:
        return "<??? 7>";
    case KeyEvent.KEYCODE_SPACE:
        return "<Space>";
    case KeyEvent.KEYCODE_STAR:
        return "<*>";
    case KeyEvent.KEYCODE_SYM:
        return "<Sym>";
    case KeyEvent.KEYCODE_TAB:
        return "<Tab>";
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        return "<VolumeDown>";
    case KeyEvent.KEYCODE_VOLUME_UP:
        return "<VolumeUp>";
    case KeyEvent.KEYCODE_UNKNOWN:
    default:/*from   ww  w.j  a v a  2  s.c  o m*/
        return "<Unknown>";
    }
}

From source file:au.com.cybersearch2.classyfy.MainActivityTest.java

public void test_search() throws Throwable {
    final MainActivity mainActivity = getActivity();
    Instrumentation instrumentation = getInstrumentation();
    ActivityMonitor am = instrumentation.addMonitor(TitleSearchResultsActivity.class.getName(), null, false);
    assertThat(instrumentation.invokeMenuActionSync(mainActivity, R.id.action_search, 0)).isTrue();
    ActionBar actionBar = mainActivity.getSupportActionBar();
    assertThat(actionBar).isNotNull();/*from  w w w.  j  ava  2 s .c o m*/
    final FragmentManager sfm = mainActivity.getSupportFragmentManager();
    runTestOnUiThread(new Runnable() {
        public void run() {
            sfm.executePendingTransactions();
        }
    });
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_I);
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_N);
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_F);
    instrumentation.sendCharacterSync(KeyEvent.KEYCODE_ENTER);
    runTestOnUiThread(new Runnable() {
        public void run() {
            sfm.executePendingTransactions();
        }
    });
    TitleSearchResultsActivity titleSearchResultsActivity = (TitleSearchResultsActivity) getInstrumentation()
            .waitForMonitorWithTimeout(am, 10000);
    assertThat(titleSearchResultsActivity).isNotNull();
    assertThat(titleSearchResultsActivity.taskHandle).isNotNull();
    synchronized (titleSearchResultsActivity.taskHandle) {
        titleSearchResultsActivity.taskHandle.wait(10000);
    }
    assertThat(titleSearchResultsActivity.taskHandle.getStatus()).isEqualTo(WorkStatus.FINISHED);
    SimpleCursorAdapter adapter = titleSearchResultsActivity.adapter;
    for (int i = 0; i < adapter.getCount(); i++) {
        Cursor cursor = (Cursor) adapter.getItem(i);
        int column = cursor.getColumnIndexOrThrow(SearchManager.SUGGEST_COLUMN_TEXT_1);
        assertThat(INF_LIST[i]).isEqualTo(cursor.getString(column));
    }
}

From source file:research.sg.edu.edapp.kb.KbSoftKeyboard.java

/**
 * Use this to monitor key events being delivered to the application.
 * We get first crack at them, and can either resume them or let them
 * continue to the app./*from  w w  w  .j av  a2 s .  c om*/
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    String s = "" + event.getUnicodeChar();
    Log.d("CAME HERE", "CAME HERE");
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        // The InputMethodService already takes care of the back
        // key for us, to dismiss the input method if it is shown.
        // However, our keyboard could be showing a pop-up window
        // that back should dismiss, so we first allow it to do that.

        if (event.getRepeatCount() == 0 && mInputView != null) {
            if (mInputView.handleBack()) {
                return true;
            }
        }
        break;

    case KeyEvent.KEYCODE_DEL:
        // Special handling of the delete key: if we currently are
        // composing text for the user, we want to modify that instead
        // of let the application to the delete itself.
        if (mComposing.length() > 0) {
            onKey(Keyboard.KEYCODE_DELETE, null);
            return true;
        }
        break;

    case KeyEvent.KEYCODE_ENTER:
        // Let the underlying text editor always handle these.
        return false;

    default:
        // For all other keys, if we want to do transformations on
        // text being entered with a hard keyboard, we need to process
        // it and do the appropriate action.

        if (PROCESS_HARD_KEYS) {
            //*********added changes here
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                swipe += (char) event.getUnicodeChar();
                Log.d("msg", swipe);
                System.out.println(swipe);
                // keyDownUp(keyCode);
                //   return true;
            }
            //*********done
            if (keyCode == KeyEvent.KEYCODE_SPACE && (event.getMetaState() & KeyEvent.META_ALT_ON) != 0) {
                // A silly example: in our input method, Alt+Space
                // is a shortcut for 'android' in lower case.
                InputConnection ic = getCurrentInputConnection();
                if (ic != null) {
                    // First, tell the editor that it is no longer in the
                    // shift state, since we are consuming this.
                    ic.clearMetaKeyStates(KeyEvent.META_ALT_ON);
                    keyDownUp(KeyEvent.KEYCODE_A);
                    keyDownUp(KeyEvent.KEYCODE_N);
                    keyDownUp(KeyEvent.KEYCODE_D);
                    keyDownUp(KeyEvent.KEYCODE_R);
                    keyDownUp(KeyEvent.KEYCODE_O);
                    keyDownUp(KeyEvent.KEYCODE_I);
                    keyDownUp(KeyEvent.KEYCODE_D);
                    // And we consume this event.
                    return true;
                }

            }

            if (mPredictionOn && translateKeyDown(keyCode, event)) {
                return true;
            }

        }
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.google.android.apps.mytracks.TrackDetailActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_M:
        if (trackId == recordingTrackId) {
            // Recording
            insertMarkerAction();/*from  ww  w .ja v a 2  s .  c  o m*/
        }
        break;
    case KeyEvent.KEYCODE_H:
        if (tabHost.getCurrentTab() == 1) {
            ChartFragment f = (ChartFragment) tabManager.getCurrentFragment();
            f.scrollLeft();
        }
        break;
    case KeyEvent.KEYCODE_K:
        if (tabHost.getCurrentTab() == 1) {
            ChartFragment f = (ChartFragment) tabManager.getCurrentFragment();
            f.scrollRight();
        }
        break;
    case KeyEvent.KEYCODE_0:
        if (tabHost.getCurrentTab() == 2) {
            MapFragment f = (MapFragment) tabManager.getCurrentFragment();
            f.showMyLocation();
        }
        break;

    case KeyEvent.KEYCODE_Q:
        tabHost.setCurrentTab(0);
        break;

    case KeyEvent.KEYCODE_SPACE:
        if ((tabHost.getCurrentTab() == 1)
                && PreferencesUtils.getBoolean(this, R.string.settings_mapsprovider, true)) {
            // Use nogago Maps
        } else {
            tabHost.setCurrentTab(tabHost.getCurrentTab() + 1);
        }
        break;

    case KeyEvent.KEYCODE_I:
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        if (tabHost.getCurrentTab() == 0) {
            Toast.makeText(getApplicationContext(), "Cannot zoom in on statistics", Toast.LENGTH_SHORT).show();
        } else if (tabHost.getCurrentTab() == 1) {
            ChartFragment f = (ChartFragment) tabManager.getCurrentFragment();
            f.zoomIn();
            // Toast.makeText(getApplicationContext(), "Currently at " +
            // f.getClass().toString(), Toast.LENGTH_SHORT).show();
        } else if (tabHost.getCurrentTab() == 2) {
            MapFragment f = (MapFragment) tabManager.getCurrentFragment();
            f.zoomIn();
            // Toast.makeText(getApplicationContext(), "Currently at " +
            // f.getClass().toString(), Toast.LENGTH_SHORT).show();
        }
        break;
    case KeyEvent.KEYCODE_O:
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (tabHost.getCurrentTab() == 0) {
            Toast.makeText(getApplicationContext(), "Cannot zoom in on statistics", Toast.LENGTH_SHORT).show();
        } else if (tabHost.getCurrentTab() == 1) {
            ChartFragment f = (ChartFragment) tabManager.getCurrentFragment();
            f.zoomOut();
            // Toast.makeText(getApplicationContext(), "Currently at " +
            // f.getClass().toString(), Toast.LENGTH_SHORT).show();
        } else if (tabHost.getCurrentTab() == 2) {
            MapFragment f = (MapFragment) tabManager.getCurrentFragment();
            f.zoomOut();
            // Toast.makeText(getApplicationContext(), "Currently at " +
            // f.getClass().toString(), Toast.LENGTH_SHORT).show();
        }
        break;
    case KeyEvent.KEYCODE_P:
        if (recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT) {
            if (recordingTrackPaused) {
                // Paused -> Resume
                Toast.makeText(getApplicationContext(), "Resumed Recording", Toast.LENGTH_LONG).show();
                AnalyticsUtils.sendPageViews(TrackDetailActivity.this, "/action/detail/resume_track");
                updateMenuItems(true, false);
                TrackRecordingServiceConnectionUtils.resumeTrack(trackRecordingServiceConnection);
                trackController.update(true, false);
            } else {
                // Recording -> Paused
                Toast.makeText(getApplicationContext(), "Paused Recording", Toast.LENGTH_LONG).show();
                AnalyticsUtils.sendPageViews(TrackDetailActivity.this, "/action/detail/pause_track");
                updateMenuItems(true, true);
                TrackRecordingServiceConnectionUtils.pauseTrack(trackRecordingServiceConnection);
                trackController.update(true, true);
            }
        } else {
            Toast.makeText(getApplicationContext(), "Cannot pause track that is not recorded.",
                    Toast.LENGTH_LONG).show();
        }
        break;

    case KeyEvent.KEYCODE_S:
        AnalyticsUtils.sendPageViews(TrackDetailActivity.this, "/action/detail/stop_recording");
        updateMenuItems(false, true);
        TrackRecordingServiceConnectionUtils.stopRecording(TrackDetailActivity.this,
                trackRecordingServiceConnection, true);
        break;

    case KeyEvent.KEYCODE_A:
        Intent intent = IntentUtils.newIntent(this, SettingsActivity.class);
        startActivity(intent);
        break;

    }

    return super.onKeyUp(keyCode, event);
}

From source file:com.android.tv.ui.TvOverlayManager.java

/**
 * Handles the onKeyUp event of the {@link MainActivity}.
 *//*from  w w  w  . j  a va 2  s.  co m*/
@KeyHandlerResultType
public int onKeyUp(int keyCode, KeyEvent event) {
    // Handle media key here because it is related to the menu.
    if (isMediaStartKey(keyCode)) {
        // The media key should not be passed up to the system in any cases.
        if (mCurrentDialog != null || mProgramGuide.isActive() || mSideFragmentManager.isActive()
                || mSearchFragment.isVisible() || mTransitionManager.isKeypadChannelSwitchActive()
                || mTransitionManager.isSelectInputActive() || mSetupFragmentActive
                || mNewSourcesFragmentActive) {
            // Do not handle media key when any pop-ups which can handle keys are active.
            return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
        }
        TimeShiftManager timeShiftManager = mMainActivity.getTimeShiftManager();
        if (!timeShiftManager.isAvailable()) {
            return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
        }
        switch (keyCode) {
        case KeyEvent.KEYCODE_MEDIA_PLAY:
            timeShiftManager.play();
            showMenu(Menu.REASON_PLAY_CONTROLS_PLAY);
            break;
        case KeyEvent.KEYCODE_MEDIA_PAUSE:
            timeShiftManager.pause();
            showMenu(Menu.REASON_PLAY_CONTROLS_PAUSE);
            break;
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
            timeShiftManager.togglePlayPause();
            showMenu(Menu.REASON_PLAY_CONTROLS_PLAY_PAUSE);
            break;
        case KeyEvent.KEYCODE_MEDIA_REWIND:
            timeShiftManager.rewind();
            showMenu(Menu.REASON_PLAY_CONTROLS_REWIND);
            break;
        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
            timeShiftManager.fastForward();
            showMenu(Menu.REASON_PLAY_CONTROLS_FAST_FORWARD);
            break;
        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
            timeShiftManager.jumpToPrevious();
            showMenu(Menu.REASON_PLAY_CONTROLS_JUMP_TO_PREVIOUS);
            break;
        case KeyEvent.KEYCODE_MEDIA_NEXT:
            timeShiftManager.jumpToNext();
            showMenu(Menu.REASON_PLAY_CONTROLS_JUMP_TO_NEXT);
            break;
        default:
            // Does nothing.
            break;
        }
        return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
    }
    if (keyCode == KeyEvent.KEYCODE_I || keyCode == KeyEvent.KEYCODE_TV_INPUT) {
        if (mTransitionManager.isSelectInputActive()) {
            mSelectInputView.onKeyUp(keyCode, event);
        } else {
            showSelectInputView();
        }
        return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
    }
    if (mCurrentDialog != null) {
        // Consumes the keys while a Dialog is showing.
        // This can be happen while a Dialog isn't created yet.
        return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
    }
    if (mProgramGuide.isActive()) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            mProgramGuide.onBackPressed();
            return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
        }
        return MainActivity.KEY_EVENT_HANDLER_RESULT_DISPATCH_TO_OVERLAY;
    }
    if (mSideFragmentManager.isActive()) {
        if (keyCode == KeyEvent.KEYCODE_BACK || mSideFragmentManager.isHideKeyForCurrentPanel(keyCode)) {
            mSideFragmentManager.popSideFragment();
            return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
        }
        return MainActivity.KEY_EVENT_HANDLER_RESULT_DISPATCH_TO_OVERLAY;
    }
    if (mMenu.isActive() || mTransitionManager.isSceneActive()) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            TimeShiftManager timeShiftManager = mMainActivity.getTimeShiftManager();
            if (timeShiftManager.isPaused()) {
                timeShiftManager.play();
            }
            hideOverlays(TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_SIDE_PANELS
                    | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_DIALOG
                    | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_FRAGMENT);
            return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
        }
        if (mMenu.isActive()) {
            if (KeypadChannelSwitchView.isChannelNumberKey(keyCode)) {
                mMainActivity.showKeypadChannelSwitchView(keyCode);
                return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
            }
            return MainActivity.KEY_EVENT_HANDLER_RESULT_DISPATCH_TO_OVERLAY;
        }
    }
    if (mTransitionManager.isKeypadChannelSwitchActive()) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            mTransitionManager.goToEmptyScene(true);
            return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
        }
        return mKeypadChannelSwitchView.onKeyUp(keyCode, event) ? MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED
                : MainActivity.KEY_EVENT_HANDLER_RESULT_NOT_HANDLED;
    }
    if (mTransitionManager.isSelectInputActive()) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            mTransitionManager.goToEmptyScene(true);
            return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
        }
        return mSelectInputView.onKeyUp(keyCode, event) ? MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED
                : MainActivity.KEY_EVENT_HANDLER_RESULT_NOT_HANDLED;
    }
    if (mSetupFragmentActive) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            closeSetupFragment(true);
            return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
        }
        return MainActivity.KEY_EVENT_HANDLER_RESULT_DISPATCH_TO_OVERLAY;
    }
    if (mNewSourcesFragmentActive) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            closeNewSourcesFragment(true);
            return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED;
        }
        return MainActivity.KEY_EVENT_HANDLER_RESULT_DISPATCH_TO_OVERLAY;
    }
    return MainActivity.KEY_EVENT_HANDLER_RESULT_PASSTHROUGH;
}

From source file:com.strathclyde.highlightingkeyboard.SoftKeyboardService.java

/**
 * Use this to monitor key events being delivered to the application.
 * We get first crack at them, and can either resume them or let them
 * continue to the app./*from w w  w .  j  a v  a 2 s. c  o m*/
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    //event.
    //Log.i("OnKeyDown", "Keycode: "+keyCode);
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        // The InputMethodService already takes care of the back
        // key for us, to dismiss the input method if it is shown.
        // However, our keyboard could be showing a pop-up window
        // that back should dismiss, so we first allow it to do that.
        if (event.getRepeatCount() == 0 && mInputView != null) {
            if (mInputView.handleBack()) {
                return true;
            }
        }
        break;

    case KeyEvent.KEYCODE_DEL:
        // Special handling of the delete key: if we currently are
        // composing text for the user, we want to modify that instead
        // of let the application to the delete itself.
        if (mComposing.length() > 0) {
            onKey(Keyboard.KEYCODE_DELETE, null);
            return true;
        }
        break;

    case -2: //123 button
        //Log.i("KeyDown", "Keycode: "+keyCode);
        event.startTracking();
        return true;

    case KeyEvent.KEYCODE_ENTER:
        // Let the underlying text editor always handle these.
        return false;

    default:
        // For all other keys, if we want to do transformations on
        // text being entered with a hard keyboard, we need to process
        // it and do the appropriate action.
        if (PROCESS_HARD_KEYS) {
            if (keyCode == KeyEvent.KEYCODE_SPACE && (event.getMetaState() & KeyEvent.META_ALT_ON) != 0) {
                // A silly example: in our input method, Alt+Space
                // is a shortcut for 'android' in lower case.
                //InputConnection ic = ic;
                if (ic != null) {
                    // First, tell the editor that it is no longer in the
                    // shift state, since we are consuming this.
                    ic.clearMetaKeyStates(KeyEvent.META_ALT_ON);
                    keyDownUp(KeyEvent.KEYCODE_A);
                    keyDownUp(KeyEvent.KEYCODE_N);
                    keyDownUp(KeyEvent.KEYCODE_D);
                    keyDownUp(KeyEvent.KEYCODE_R);
                    keyDownUp(KeyEvent.KEYCODE_O);
                    keyDownUp(KeyEvent.KEYCODE_I);
                    keyDownUp(KeyEvent.KEYCODE_D);
                    // And we consume this event.
                    return true;
                }
            }
            if (mPredictionOn && translateKeyDown(keyCode, event)) {
                return true;
            }
        }
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.anysoftkeyboard.AnySoftKeyboard.java

private void sendTab() {
    InputConnection ic = getCurrentInputConnection();
    if (ic == null)
        return;//  ww w  .ja v a2  s . c o m
    boolean tabHack = isTerminalEmulation();

    // Note: tab and ^I don't work in ConnectBot, hackish workaround
    if (tabHack) {
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_CENTER));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DPAD_CENTER));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_I));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_I));
    } else {
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_TAB));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_TAB));
    }
}

From source file:org.distantshoresmedia.keyboard.LatinIME.java

private void sendTab() {
    InputConnection ic = getCurrentInputConnection();
    boolean tabHack = isConnectbot() && mConnectbotTabHack;

    // FIXME: tab and ^I don't work in connectbot, hackish workaround
    if (tabHack) {
        if (mModAlt) {
            // send ESC prefix
            ic.commitText(Character.toString((char) 27), 1);
        }/*ww  w. j  a  v  a2  s  .  com*/
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_CENTER));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DPAD_CENTER));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_I));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_I));
    } else {
        sendModifiedKeyDownUp(KeyEvent.KEYCODE_TAB);
    }
}