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


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

Re: read DEL and BACK key from stdin

From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: read DEL and BACK key from stdin
Date 2011-12-09 08:19 -0800
Organization http://groups.google.com
Message-ID <26099855.1318.1323447547152.JavaMail.geo-discussion-forums@pril5> (permalink)
References <bfaf0d1a-2933-4e82-8856-2aac14e11ce9@l29g2000yqf.googlegroups.com>

Show all headers | View raw


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

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


Thread

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

csiph-web