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


Groups > comp.lang.java.programmer > #10622 > unrolled thread

read DEL and BACK key from stdin

Started byxdevel1999 <xdevel1999@gmail.com>
First post2011-12-09 07:31 -0800
Last post2011-12-09 10:29 -0800
Articles 3 — 3 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  read DEL and BACK key from stdin xdevel1999 <xdevel1999@gmail.com> - 2011-12-09 07:31 -0800
    Re: read DEL and BACK key from stdin Lew <lewbloch@gmail.com> - 2011-12-09 08:19 -0800
    Re: read DEL and BACK key from stdin Roedy Green <see_website@mindprod.com.invalid> - 2011-12-09 10:29 -0800

#10622 — read DEL and BACK key from stdin

Fromxdevel1999 <xdevel1999@gmail.com>
Date2011-12-09 07:31 -0800
Subjectread DEL and BACK key from stdin
Message-ID<bfaf0d1a-2933-4e82-8856-2aac14e11ce9@l29g2000yqf.googlegroups.com>
Is it possible to read DEL and BACKSPACE keys from standard in?

If I use:

System.in.read()

these keys are never returned.

Thanks.

[toc] | [next] | [standalone]


#10623

FromLew <lewbloch@gmail.com>
Date2011-12-09 08:19 -0800
Message-ID<26099855.1318.1323447547152.JavaMail.geo-discussion-forums@pril5>
In reply to#10622
xdevel1999 wrote:
> 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>

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#10630

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-12-09 10:29 -0800
Message-ID<6qk4e7ta53lf0rmtc8jaif24ec5a9613mo@4ax.com>
In reply to#10622
On Fri, 9 Dec 2011 07:31:39 -0800 (PST), xdevel1999
<xdevel1999@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>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.
 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web