android.view.KeyEvent.getKeyCode()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(330)

本文整理了Java中android.view.KeyEvent.getKeyCode()方法的一些代码示例,展示了KeyEvent.getKeyCode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent.getKeyCode()方法的具体详情如下:
包路径:android.view.KeyEvent
类名称:KeyEvent
方法名:getKeyCode

KeyEvent.getKeyCode介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

@Override
public boolean onKeyDown (int keyCode, KeyEvent event) {
  Log.d("Test", "down keycode: " + event.getKeyCode());
  return super.onKeyDown(keyCode, event);
}

代码示例来源:origin: libgdx/libgdx

@Override
public boolean onKeyDown (int keyCode, KeyEvent event) {
  Log.d("Test", "down keycode: " + event.getKeyCode());
  return super.onKeyDown(keyCode, event);
}

代码示例来源:origin: libgdx/libgdx

@Override
  public boolean onKeyUp (int keyCode, KeyEvent event) {
    Log.d("Test", "up keycode: " + event.getKeyCode());
    return super.onKeyUp(keyCode, event);
  }
};

代码示例来源:origin: libgdx/libgdx

@Override
  public boolean onKeyUp (int keyCode, KeyEvent event) {
    Log.d("Test", "up keycode: " + event.getKeyCode());
    return super.onKeyUp(keyCode, event);
  }
};

代码示例来源:origin: androidannotations/androidannotations

@KeyMultiple({ KeyEvent.KEYCODE_9, KeyEvent.KEYCODE_W })
void multiple(int count, KeyEvent keyEvent) {
  switch (keyEvent.getKeyCode()) {
  case KeyEvent.KEYCODE_W:
    isWMultiple = true;
    break;
  case KeyEvent.KEYCODE_9:
    isNineMultiple = true;
    nineMultipleCount = count;
  }
}

代码示例来源:origin: cSploit/android

@Override
  public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN
        && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
      mOutput.append(Html.fromHtml("<font color=\"red\">" + mInput.getText().toString() + "</font>\n"));
      mSession.addCommand(mInput.getText().toString(), mReceiver);
      return true;
    }
    return false;
  }
});

代码示例来源:origin: pchmn/MaterialChipsInput

@Override
  public boolean onKey(View v, int keyCode, KeyEvent event) {
    // backspace
    if(event.getAction() == KeyEvent.ACTION_DOWN
        && event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
      // remove last chip
      if(mChipList.size() > 0 && mEditText.getText().toString().length() == 0)
        removeChip(mChipList.size() - 1);
    }
    return false;
  }
});

代码示例来源:origin: Jacksgong/JKeyboardPanelSwitch

@Override
  public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_UP
        && event.getKeyCode() == KeyEvent.KEYCODE_BACK
        && mPanelRoot.getVisibility() == View.VISIBLE) {
      mPanelRoot.setVisibility(View.GONE);
      return true;
    }
    return super.dispatchKeyEvent(event);
  }
}

代码示例来源:origin: k9mail/k-9

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  boolean ret = false;
  if (KeyEvent.ACTION_DOWN == event.getAction()) {
    ret = onCustomKeyDown(event.getKeyCode(), event);
  }
  if (!ret) {
    ret = super.dispatchKeyEvent(event);
  }
  return ret;
}

代码示例来源:origin: Jacksgong/JKeyboardPanelSwitch

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  if (event.getAction() == KeyEvent.ACTION_UP
      && event.getKeyCode() == KeyEvent.KEYCODE_BACK
      && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    KPSwitchConflictUtil.hidePanelAndKeyboard(mPanelRoot);
    return true;
  }
  return super.dispatchKeyEvent(event);
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
  public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_SEND || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER))  {
      onQueryTextSubmit(v.getText().toString());
      onMenuItemActionExpand(null);
      return true;
    }
    return false;
  }
});

代码示例来源:origin: square/assertj-android

public KeyEventAssert hasKeyCode(int keyCode) {
 isNotNull();
 int actualKeyCode = actual.getKeyCode();
 assertThat(actualKeyCode) //
   .overridingErrorMessage("Expected key code <%s> but was <%s>", keyCode, actualKeyCode) //
   .isEqualTo(keyCode);
 return this;
}

代码示例来源:origin: cSploit/android

@Override
 public boolean onKey(View v, int keyCode, KeyEvent event) {
  if (event.getAction() == KeyEvent.ACTION_DOWN
      && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
   mWebView.loadUrl(mURLet.getText().toString());
   InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
   imm.hideSoftInputFromWindow(mWebView.getWindowToken(), 0);
   mWebView.requestFocus();
   return true;
  }
  return false;
 }
});

代码示例来源:origin: smuyyh/BookReader

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  if (event.getAction() == KeyEvent.ACTION_DOWN
      && event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
    if (System.currentTimeMillis() - currentBackPressedTime > BACK_PRESSED_INTERVAL) {
      currentBackPressedTime = System.currentTimeMillis();
      ToastUtils.showToast(getString(R.string.exit_tips));
      return true;
    } else {
      finish(); // 退出
    }
  } else if (event.getKeyCode() == KeyEvent.KEYCODE_MENU) {
    return true;
  }
  return super.dispatchKeyEvent(event);
}

代码示例来源:origin: arimorty/floatingsearchview

@Override
public boolean onKeyPreIme(int keyCode, KeyEvent ev) {
  if (ev.getKeyCode() == KeyEvent.KEYCODE_BACK && mOnKeyboardDismissedListener != null) {
    mOnKeyboardDismissedListener.onKeyboardDismissed();
  }
  return super.onKeyPreIme(keyCode, ev);
}

代码示例来源:origin: Jacksgong/JKeyboardPanelSwitch

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  if (event.getAction() == KeyEvent.ACTION_UP
      && event.getKeyCode() == KeyEvent.KEYCODE_BACK
      && mPanelRoot.getVisibility() == View.VISIBLE) {
    KPSwitchConflictUtil.hidePanelAndKeyboard(mPanelRoot);
    return true;
  }
  return super.dispatchKeyEvent(event);
}

代码示例来源:origin: Jacksgong/JKeyboardPanelSwitch

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  if (event.getAction() == KeyEvent.ACTION_UP
      && event.getKeyCode() == KeyEvent.KEYCODE_BACK
      && panelRoot.getVisibility() != View.GONE) {
    KPSwitchConflictUtil.hidePanelAndKeyboard(panelRoot);
    return true;
  }
  return super.dispatchKeyEvent(event);
}

代码示例来源:origin: robolectric/robolectric

private int getCharacterKeyCode(char oneChar) {
 // Lowercase the character to avoid getting modifiers in the KeyEvent array.
 char[] chars = new char[] {Character.toLowerCase(oneChar)};
 KeyEvent[] events = keyCharacterMap.getEvents(chars);
 return events[0].getKeyCode();
}

代码示例来源:origin: mancj/MaterialSearchBar

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && searchEnabled) {
    animateSuggestions(getListHeight(false), 0);
    disableSearch();
    return true;
  }
  return super.dispatchKeyEvent(event);
}

代码示例来源:origin: google/ExoPlayer

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
 if (player != null && player.isPlayingAd()) {
  // Focus any overlay UI now, in case it's provided by a WebView whose contents may update
  // dynamically. This is needed to make the "Skip ad" button focused on Android TV when using
  // IMA [Internal: b/62371030].
  overlayFrameLayout.requestFocus();
  return super.dispatchKeyEvent(event);
 }
 boolean isDpadWhenControlHidden =
   isDpadKey(event.getKeyCode()) && useController && !controller.isVisible();
 boolean handled =
   isDpadWhenControlHidden || dispatchMediaKeyEvent(event) || super.dispatchKeyEvent(event);
 if (handled) {
  maybeShowController(true);
 }
 return handled;
}

相关文章