此功能在系统级别上是不可能的:有关所有可能选项的列表,请参阅
http://source.android.com/tech/input/key-character-map-files.html。
但是,如果您想在应用程序级别上使用它,您可以按如下方式对其进行编程:
import android.view.KeyEvent;
private boolean home = false;
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (event.getScanCode() == 29) //29 == CTRL_LEFT
home = true; //if we release this button, HOME needs to be invoked
else home = false; //so CTRL_LEFT was used as a modifier: no need to invoke HOME
//allow the system to pass key handling to the next listener
return super.onKeyUp(keyCode, event);
}
public boolean onKeyUp(int keyCode, KeyEvent event)
{
if (event.getScanCode() == 29 && home == true)
{
super.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HOME));
return true; //so we absorb the event
}
return super.onKeyUp(keyCode, event);
}
然后,只要此应用程序设置为接收击键(通常是隐私问题,除非您自己编写代码),它就可以处理击键并在需要时发送 HOME 按钮。
如果您决定继续这样做,则必须删除
base: fallback HOME
从你的代码。