Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #39419

How can I read individual keystrokes?

From Martin Gregorie <martin@mydomain.invalid> (Martin Gregorie)
Newsgroups comp.lang.java.programmer
Subject How can I read individual keystrokes?
Date 2020-04-05 00:17 +1200
Organization fsxNet Usenet Gateway | bbs.nz/#fsxNet
Message-ID <1961251965@f38.n261.z1.binkp.net> (permalink)

Show all headers | View raw


I have a need to read individual key presses as they are made. I'm developing 
this stuff under Linux with OpenJava 1.8 and would prefer a portable Java 
solution if that's possible.

I have a working solution, but its ugly. A small C program captures the one or 
more characters emitted as a key is pressed and sends them individually to my 
Java application over a local network session.

I've also tried using the Reader.read() method of the Reader instance returned 
by calling Console.reader() but that uses line buffering internally. As a 
result the Java code doesn't get sent anything until I hit RETURN, when all the 
characters typed since
Also, there's a good chance that the C program is using OS-specific features to 
let it capture individual keystrokes.

I have a feeling that I'm missing something obvious and so would appreciate it 
if any of you can point me in the direction of a pure Java way to capture 
individual key presses.


--
Martin    | martin at
Gregorie  | gregorie dot org

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

How can I read individual keystrokes? Martin Gregorie <martin@mydomain.invalid> (Martin Gregorie) - 2020-04-05 00:17 +1200
  Re: How can I read individual keystrokes? Eric Sosman <esosman@comcast-dot-net.invalid> (Eric Sosman) - 2020-04-04 20:38 +1200
  Re: How can I read individual keystrokes? Arne Vajhøj <arne@vajhoej.dk> (Arne Vajhøj) - 2020-04-04 22:04 +1200
    Re: How can I read individual keystrokes? Martin Gregorie <martin@mydomain.invalid> (Martin Gregorie) - 2020-04-05 11:22 +1200

csiph-web