检测哪个热键正在pressed [英] Detect which Hot keys is being pressed
本文介绍了检测哪个热键正在pressed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何可以检测该组合键被pressed?
How can I detect which key combination is being pressed?
例如我想认返回和菜单按钮幸福$ P $同时pssed或任何组合键。
For example I want to recognize Back and Menu button being pressed simultaneously or any key combination.
我想开我的应用程序的基础上,上键被pressed。
I would like to open my application on the basis on which key is being pressed.
推荐答案
我做了一个简单的调查,发现这个解决方案,它可能工作。您可以检测通过以下code pssed菜单键$ P $。
I did a simple research and found this solution and it may work. You can detect Menu key pressed by the following code.
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU && event.getAction() == KeyEvent.ACTION_DOWN) {
//Start a new thread here and run a while loop for listening to "back pressed" and trigger the event you want if the back button is pressed
} else {
//stop the started thread above
return false;
}
}
希望这可以帮助你。 Thnks。
Hope this might help you. Thnks.
这篇关于检测哪个热键正在pressed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文