监听软键盘
来源:互联网 发布:单片机控制蜂鸣器发声 编辑:程序博客网 时间:2024/04/30 13:00
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case TYPE_CLASS_STOCK:
break;
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) {
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);
}
switch (keyCode) {
case TYPE_CLASS_STOCK:
break;
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) {
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);
}
- 监听软键盘
- android 软键盘监听
- Android软键盘监听
- 监听软键盘回车
- 获得软键盘高度 监听软键盘
- Android 软键盘监听事件
- Android 监听软键盘状态
- Android软键盘监听事件
- Android 监听软键盘按键
- Android 软键盘监听事件
- android监听软键盘输入@
- Android 软键盘监听事件
- Android 软键盘监听事件
- 监听软键盘的状态
- Android-监听软键盘状态
- Android 软键盘监听事件
- Android中软键盘监听
- 监听手机软键盘按键
- 9i客户端无法“直接”使用purge recyclebin命令清理10g数据库回收站信息
- javascript绘制金融图表
- Document对象的使用:getElementById()和getElementsByTagName()方法的使用练习
- ASP.NET 页生命周期概述
- Mysql5.5.9版本主从同步配置方法
- 监听软键盘
- 小波变换教程(三)
- HTML
- JS小程序....
- php实现相关文章功能代码方法
- Tomcat 屏蔽IP解决方案
- C++ primer读书笔记之表达式
- Objective-C函数消息机制的理解
- 小笨霖英语笔记本