[java] key events in a console

Started by
1 comment, last by silencer 22 years, 7 months ago
Is it possible to catch key events in console mode, I mean without a GUI. I want ot be able to put warning messages before actually loading the graphics and maybe let the user choose alternative options ubt just by pressing a key or another, not having to type a line (with a CR). System.in is an InputStream but it seems to act more like a buffered one as nothing can be read from it until a CR as been sent. On the other hand, KeyEvents seem to be only for GUI Components which also must have the focus. Do you hava any idea ? Or maybe it is not possible in java. PS: also, is there an API or something else that could do the same as ncurses in C ? Not really game related (although I would use it for my configuration program) but I was just wondering...
Advertisement
Console mode == no events. System.in is your friend.
As for working with C, check out JNI.

"If consquences dictate our course of action, it doesn''t matter what''s right, it''s only wrong if you get caught."
- Tool
"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they're organized along the lines of the mafia." -Kurt Vonnegut
What about a simple AWT based dialog box or simple window. This would be quick, and allow for single character changes. System.in does not allow what you are trying to do.

This topic is closed to new replies.

Advertisement