简体   繁体   English

未按下组合键时的Java

[英]Java While Key Combination Not Pressed

i have a java command prompt that look for file changes in the directory and then edits the file. 我有一个Java命令提示符,在目录中查找文件更改,然后编辑文件。

I want to have a key combination like "Crtl + E" to exit the program. 我想使用“ Crtl + E”之类的组合键退出该程序。 The code should be like: 该代码应类似于:

while(keyCom.NOTpressed){
**edit file**
}

Thank for help. 感谢您的帮助。

I hope you meant checking key event from console and not from UI (Swing/Html etc). 我希望您的意思是从控制台而不是从UI(Swing / Html等)检查关键事件。

Key event capturing from console is tougher than what it seems initially. 从控制台捕获关键事件比最初看起来要困难。 It requires some native support. 它需要一些本机支持。

Found this library here http://sourceforge.net/projects/javacurses/ maybe you can take a look. http://sourceforge.net/projects/javacurses/处找到此库,也许您可​​以看看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM