Read character from keyboard

Discussion in 'Ruby' started by André Wagner, Aug 12, 2003.

  1. Hello,

    I wonder if it's possible to read a character from the keyboard
    without pressing enter...

    Thank you in advance,

    André

    --
    © André Wagner - 2003 - All rights reserved
    André Wagner, Aug 12, 2003
    #1
    1. Advertising

  2. André Wagner

    Guest

    Hi,

    At Wed, 13 Aug 2003 05:18:50 +0900,
    André Wagner wrote:
    > I wonder if it's possible to read a character from the keyboard
    > without pressing enter...


    It is completely system dependent issue. Which platform do you
    use?

    On Unixes, you can disable tty input canononical mode or
    setting it raw mode, and read 1 byte.

    --
    Nobu Nakada
    , Aug 13, 2003
    #2
    1. Advertising

  3. André Wagner

    Alan Davies Guest

    I've been trying to do something similar. It would appear that there is
    a bug in the windows implementation of gets which causes it to block the
    entire process instead of the thread.

    In article <>, André Wagner"
    <> says...
    > In Tuesday, August 12, 2003 you wrote:
    >
    > >> I wonder if it's possible to read a character from the keyboard
    > >> without pressing enter...

    >
    > > It is completely system dependent issue. Which platform do you
    > > use?

    >
    > Hmmm... I'm using Windows now, but I wish my application to be
    > platform independent.
    >
    > What I'm trying to write is a server on which you can type commands
    > (like a prompt). So I would have two threads: one for the server
    > processing (the socket) and another one for the prompt. The problem is
    > that the socket thread won't write anything on the screen (like a
    > warning message) if the prompt thread is waiting for a input.
    >
    > I'm not sure if I made myself clear... but is there any other way I
    > can do that?
    >
    > Thank you in advance.
    >
    >
    Alan Davies, Aug 13, 2003
    #3
  4. In article <>, André Wagner wrote:
    > What I'm trying to write is a server on which you can type commands
    > (like a prompt). So I would have two threads: one for the server
    > processing (the socket) and another one for the prompt. The problem is
    > that the socket thread won't write anything on the screen (like a
    > warning message) if the prompt thread is waiting for a input.


    One way might be to use "select" on your socket and stdin.
    Jason Williams, Aug 13, 2003
    #4
    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. Tommy Grav

    Reading character from keyboard

    Tommy Grav, Jan 23, 2007, in forum: Python
    Replies:
    3
    Views:
    402
    Gabriel Genellina
    Jan 23, 2007
  2. begin_ner
    Replies:
    0
    Views:
    448
    begin_ner
    Jan 3, 2008
  3. Luo Yong
    Replies:
    13
    Views:
    214
    David Vallner
    Oct 1, 2006
  4. PerlFAQ Server
    Replies:
    0
    Views:
    91
    PerlFAQ Server
    Jan 29, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    103
    PerlFAQ Server
    Mar 28, 2011
Loading...

Share This Page