Example usage for android.view KeyEvent getKeyCode

List of usage examples for android.view KeyEvent getKeyCode

Introduction

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

Prototype

public final int getKeyCode() 

Source Link

Document

Retrieve the key code of the key event.

Usage

From source file:com.dmbstream.android.activity.SearchResultsActivity.java

@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
    switch (keyEvent.getKeyCode()) {
    case KeyEvent.KEYCODE_SEARCH:
    case KeyEvent.KEYCODE_ENTER:
        AnalyticsUtil.trackEvent(SearchResultsActivity.this, "SearchResults", "Enter", "Query", 0);
        search();/* w  w w.ja v  a 2 s .c o m*/
        return true;
    }
    return false;
}

From source file:de.appetites.android.menuItemSearchAction.MenuItemSearchAction.java

/**
 * Listen for back button clicks, in order to close the keyboard and collapse the ActionView
 *//*from   w  ww.j  av a2s .  c  o m*/
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
        searchItem.collapseActionView();
    } else if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
        searchPerformListener.performSearch(MenuItemSearchAction.this.getText().toString());

        searchItem.collapseActionView();

    }
    return super.dispatchKeyEvent(event);
}

From source file:com.irccloud.android.ActionEditText.java

@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
    if (mDrawerLayout != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK
            && event.getAction() == KeyEvent.ACTION_UP) {
        mDrawerLayout.closeDrawers();//from  w w w .j a  v a2 s.  co m
    }
    return super.onKeyPreIme(keyCode, event);
}

From source file:com.razerzone.store.sdk.engine.gamemaker.Plugin.java

public static boolean onKeyUp(int keyCode, KeyEvent keyEvent) {
    if (sEnableInputLogging) {
        Log.d(TAG, "onKeyUp keyCode=" + DebugInput.debugGetButtonName(keyEvent.getKeyCode()));
    }/*from  w w  w  .ja  v  a  2s .  c  om*/
    if (null != sInputView) {
        return sInputView.onKeyUp(keyCode, keyEvent);
    }
    return true;
}

From source file:com.razerzone.store.sdk.engine.gamemaker.Plugin.java

public static boolean onKeyDown(int keyCode, KeyEvent keyEvent) {
    if (sEnableInputLogging) {
        Log.d(TAG, "onKeyDown keyCode=" + DebugInput.debugGetButtonName(keyEvent.getKeyCode()));
    }//  w w w.  j  av a 2  s.  c om
    if (null != sInputView) {
        return sInputView.onKeyDown(keyCode, keyEvent);
    }
    return true;
}

From source file:org.deviceconnect.android.deviceplugin.theta.activity.ThetaFeatureActivity.java

@Override
public boolean dispatchKeyEvent(final KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_BACK:
            finish();/*from   ww w .j a  v a2  s  . c o m*/
            break;
        default:
            break;
        }
    }
    return super.dispatchKeyEvent(event);
}

From source file:com.razerzone.store.sdk.engine.gamemaker.Plugin.java

public static boolean dispatchKeyEvent(KeyEvent keyEvent) {
    if (sEnableInputLogging) {
        Log.d(TAG, "dispatchKeyEvent keyCode=" + DebugInput.debugGetButtonName(keyEvent.getKeyCode()));
    }//ww  w  . j  ava  2 s  .  c om
    if (null != sInputView) {
        return sInputView.dispatchKeyEvent(keyEvent);
    }
    return true;
}

From source file:net.simno.klingar.ui.LoginController.java

@OnEditorAction(R.id.password_edit)
boolean onPasswordEditorAction(TextView view, int actionId, KeyEvent event) {
    if ((event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)
            || (actionId == EditorInfo.IME_ACTION_DONE)) {
        login();//from  www. ja v a  2  s .c o  m
        return true;
    }
    return false;
}

From source file:com.yuntongxun.ecdemo.ui.chatting.ChattingActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    LogUtil.d(TAG, "chatting ui dispatch key event :" + event);
    if (mChattingFragment != null && mChattingFragment.onKeyDown(event.getKeyCode(), event)) {
        return true;
    }/*ww w.j a v  a  2s.c  o m*/
    return super.dispatchKeyEvent(event);
}

From source file:com.gao.im.ui.CCPFragment.java

/**
 * ?//from w w  w.  j  a va2s . c  o  m
 * @param keyCode
 * @param event
 * @return
 */
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK) && event.getAction() == KeyEvent.ACTION_DOWN) {
        finish();
        return true;
    }
    return false;
}