From: Roedy Green on
On Thu, 11 Feb 2010 12:05:09 -0800 (PST), Marcin Rodzik
<marteno_rodia(a)o2.pl> wrote, quoted or indirectly quoted someone who
said :

>Is there any way to track down keys pressed by the user in a console
>app? It means reading what he/she is typing immediately.

yes. For source see http://mindprod.com/products.html#KEYPLAYER
--
Roedy Green Canadian Mind Products
http://mindprod.com

Every compilable program in a sense works. The problem is with your unrealistic expections on what it will do.
From: Arne Vajhøj on
On 12-02-2010 06:53, Martin Gregorie wrote:
> On Thu, 11 Feb 2010 21:10:37 -0500, Arne Vajhøj wrote:
>
>> On 11-02-2010 19:56, Martin Gregorie wrote:
>>> On Thu, 11 Feb 2010 18:52:43 -0500, Arne Vajhøj wrote:
>>>
>>>> On 11-02-2010 15:05, Marcin Rodzik wrote:
>>>>> Is there any way to track down keys pressed by the user in a console
>>>>> app? It means reading what he/she is typing immediately. You can read
>>>>> the standard input stream, but the stream is empty until the user
>>>>> presses ENTER. I know it's a stuff related to the operating system
>>>>> which always passes data to the stdin after ENTER is hit, but I'm
>>>>> looking for some workaround. And it needs to work on both Windows and
>>>>> Unix/Linux. Any ideas?
>>>>
>>>> JNI and a .dll for Windows and a .so for Linux.
>>>>
>>> I've done the same with a small C program using sockets to pass each
>>> keystroke to the Java app. as a separate packet. It works well and has
>>> a possible advantage because its portable between OSes with no changed
>>> to JNI etc. The C program requires a bit of conditional compilation to
>>> cater for the different ways that different OSes use to set keyboard
>>> input to unbuffered raw reads, but thats about it.
>>
>> Why is a Java program with 1 C source and N executables more portable
>> than a Java program with 1 C source and N libraries ?
>>
> I was taking the comment that a JNI would use a .DLL for Windows and
> a .so for *nixen to mean a change to the JNI code as well. Am I mistaken?

If the C code compiled to executable can be ifdef'ed to do both
Linux and Windows, then the C code compiled to libraries for the
same two platforms can be ifdef'ed.

Arne
From: Arne Vajhøj on
On 12-02-2010 15:21, Roedy Green wrote:
> On Thu, 11 Feb 2010 12:05:09 -0800 (PST), Marcin Rodzik
> <marteno_rodia(a)o2.pl> wrote, quoted or indirectly quoted someone who
> said :
>> Is there any way to track down keys pressed by the user in a console
>> app? It means reading what he/she is typing immediately.
>
> yes. For source see http://mindprod.com/products.html#KEYPLAYER

Since when has java.awt.Frame been a console ??

Arne