read DEL and BACK key from stdin

Discussion in 'Java' started by xdevel1999, Dec 9, 2011.

  1. xdevel1999

    xdevel1999 Guest

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

    If I use:

    System.in.read()

    these keys are never returned.

    Thanks.
     
    xdevel1999, Dec 9, 2011
    #1
    1. Advertising

  2. xdevel1999

    Lew Guest

    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
     
    Lew, Dec 9, 2011
    #2
    1. Advertising

  3. xdevel1999

    Roedy Green Guest

    On Fri, 9 Dec 2011 07:31:39 -0800 (PST), xdevel1999
    <> 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.
     
    Roedy Green, Dec 9, 2011
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charlie Zender

    Reading stdin once confuses second stdin read

    Charlie Zender, Jun 19, 2004, in forum: C Programming
    Replies:
    6
    Views:
    803
    Dan Pop
    Jun 21, 2004
  2. Ken
    Replies:
    0
    Views:
    457
  3. eap.britzkrieg
    Replies:
    4
    Views:
    2,031
    Eder Perez
    Jun 8, 2009
  4. jenp
    Replies:
    0
    Views:
    95
  5. Kenneth McDonald
    Replies:
    3
    Views:
    144
    James Gray
    Sep 5, 2008
Loading...

Share This Page