Of course most programs are not attached to a consol and they talk to
the keyboard just fine. Whether my non-gui application should or should
not receive inputs from keyboard is none-of-...Oh well, let's be
nice,...lets just say that in my case it really makes sense to have no
windows and still listen to the keyboard.
Since my problem came up, I have done some reading about signals. They
are useless because they are so antiquated. Signals probably made sense
in a UNIX like environment 20 years ago when the idea of socket and
thread was not within the reach of a typical C program. Here is the
solution that I came up with that solved my problem. Unfortunately, it
is not a pure java solution. Although, it could be made into one, if
SUN introduced an OS specific class (java.awt.KeyboardInterceptor,
perhaps?) similar to other peered classes.
My idea is very simple. Write an OS specific program that sends a copy
of all keys pressed to a (host/port) -- non-blocking write (If SUN
volunteers, this would be the part that they write for all supported
OS's.) In your java program (or any other program) have a thread that
listens to that (port) and communicates with other threads. Done!
Conceivably, the KeyboardInterceptor class (the native program) could
be made more elaborate by sending certain key sequences to certain
host/port. So in this scenario, you would register a set of key
bindings to a host/port with KeyboardInterceptor and then you don't
have to listen to all keys...beats the hell outta signals--which ar OS
specific anyway. Nay?