At 05:25 PM 4/23/2001, Janet Lee wrote:
>Hi all.
>
>I'm trying to do what I think is a very simple thing. I want to read
>keyboard input char by char and time the difference between each keystroke.
>I've tried using
>
>while (sysread STDIN, $key, 1) {
>         dostuff
>};
>
>but that seems to be doing some kind of buffering so that the body of the
>while loop is only executed after a carriage return. i'm using activeperl on
>a windows machine. is it possible to do what i want to do in perl? is there
>another call i should be using? TIA
>
>janet


The reason why some of this is going on (only executing after the return) 
probably has to do with input buffering and such.  I thought sysread was 
supposed to bypass that (that is, read from the file, really, not the 
buffer that's hanging around looking like the file, but I could be 
wrong.)  You may be able to do some stuff to STDIN to turn all the 
buffering off, but I think that might be more trouble than it's worth.  I 
think the module that you want is:

http://search.cpan.org/search?dist=TermReadKey

You can install it with PPM, no problem.  If you need help with that, just 
write back to the list saying so.

Thank you for your time,

Sean.

Reply via email to