read DEL and BACK key from stdin

X

xdevel1999

Is it possible to read DEL and BACKSPACE keys from standard in?

If I use:

System.in.read()

these keys are never returned.

Thanks.
 
L

Lew

xdevel1999 said:
Is it possible to read DEL and BACKSPACE keys from standard in?

If I use:

System.in.read()

these keys are never returned.

It is only possible to read what the OS puts into the input stream. What is
the behavior of stdin from the OS point of view?

On your platform and most that we know, the OS buffers input on that stream
until it receives an end-of-line. That line is passed entire to Java to wrap
as an 'InputStream' input. It follows trivially that the Java stream cannot
see the characters you describe unless you escape them.

Have you escaped them?

"Never" is a very strong word.

<http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#in>
public static final InputStream in

<http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html>
 
R

Roedy Green

Is it possible to read DEL and BACKSPACE keys from standard in?

I don't think you see anything until the user hits enter.

If you want to see things in a keystroke by keystroke way you need
some sort of gui TextField or the like where you can intercept the
event for each keystroke.

The other way to do it is to use C.
--
Roedy Green Canadian Mind Products
http://mindprod.com
For me, the appeal of computer programming is that
even though I am quite a klutz,
I can still produce something, in a sense
perfect, because the computer gives me as many
chances as I please to get it right.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top