Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Read character from keyboard

Reply
Thread Tools

Read character from keyboard

 
 
André Wagner
Guest
Posts: n/a
 
      08-12-2003
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


 
Reply With Quote
 
 
 
 
nobu.nokada@softhome.net
Guest
Posts: n/a
 
      08-13-2003
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

 
Reply With Quote
 
 
 
 
Alan Davies
Guest
Posts: n/a
 
      08-13-2003
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 <(E-Mail Removed)>, André Wagner"
<(E-Mail Removed)> 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.
>
>

 
Reply With Quote
 
Jason Williams
Guest
Posts: n/a
 
      08-13-2003
In article <(E-Mail Removed)>, 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 5.31 How can I read a single character from a file? From the keyboard? PerlFAQ Server Perl Misc 0 03-28-2011 04:00 AM
FAQ 5.31 How can I read a single character from a file? From the keyboard? PerlFAQ Server Perl Misc 0 01-29-2011 11:00 AM
Reading character from keyboard Tommy Grav Python 3 01-23-2007 06:56 PM
Strange WinXP Pro problem: Keyboard press does not result in desired character on screen Jimmy Dean Computer Support 5 05-06-2006 12:57 AM
Keyboard error or no keyboard present??? Bud Light Computer Support 2 01-22-2005 04:00 AM



Advertisments