Java命令提示符中的键绑定? [英] Key Bindings in Command Prompt with Java?

查看:86
本文介绍了Java命令提示符中的键绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java程序在命令提示符中循环运行(我打开命令提示符并执行Java命令).我想设置一些键绑定(例如ctrl + q),以便我可以在Java程序运行时退出(该程序通过while循环运行).反正有这样做吗?我试图使用键映射,但没有使其正常工作.自定义键映射在命令提示符下不起作用吗?

I have a java program running in a loop in command prompt (I open command prompt and execute a java command). I wanted to setup some key binding (like ctrl+q) so that I could exit the java program while it is running (the program is running through a while loop). Is there anyway to do this? I was trying to use key mappings but wasn't getting it to work. Do custom key mappings not work in command prompt?

推荐答案

正如keith.layne所指出的,这是特定于操作系统的.

As keith.layne points out, this is OS specific.

对于控制台程序,操作系统为程序提供输入流.按下的键将发送到该输入流,但是如果程序不读取它们,则OS对此将不执行任何操作.另外,某些特殊组合(例如CTRL-C)会被操作系统拦截,并导致其执行某些操作(通常会杀死进程).

For console programs, the OS provides an inputstream to the program. Keys pressed are sent to that inputstream, but if the program does not read them the OS does nothing about it. Also, some special combinations (CTRL-C, by example) are intercepted by the OS and causes it to do certain actions (usually kill the process).

这篇关于Java命令提示符中的键绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆