reading the keyboard in cbreak mode 
Author Message
 reading the keyboard in cbreak mode

I am doing somethinlg like: print while (<>)
I want to read single keys from the keyboard.

If I do either stty -raw or stty -cbreak before running the script, it
still waits until it gets a newline.

Pls help.

************************************************************************
Il brilgue: les t^ oves libricilleux
    Se gyrent et frillant dans le guave,
Enm^ im' es sont les gougebosquex,
    Et le m^ omerade horgrave.


          hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer



Fri, 10 Oct 1997 03:00:00 GMT  
 reading the keyboard in cbreak mode

Quote:
>I am doing somethinlg like: print while (<>)
>I want to read single keys from the keyboard.
>If I do either stty -raw or stty -cbreak before running the script, it
>still waits until it gets a newline.

That's because the <> construct read upto and including the next newline
character.

Try:

        system("stty cbreak -echo");

        do {
                $char = getc;
                print "You typed a $char\n";
        } until $char eq 'Q';

        system("stty cooked echo");

--
Hope this helps,

HansM



Sat, 11 Oct 1997 03:00:00 GMT  
 reading the keyboard in cbreak mode
: I am doing somethinlg like: print while (<>)
: I want to read single keys from the keyboard.

: If I do either stty -raw or stty -cbreak before running the script, it
: still waits until it gets a newline.

That's because <> waits for a newline.

Try getch instead.
--




Mon, 13 Oct 1997 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Putting STDIN into cbreak mode?

2. cbreak mode in DOS ???

3. CBREAK mode in MS-DOS ==== SAMPLE CODE ====

4. Cbreak-style input in Perl for DOS (yes, I've read the FAQ)

5. keyboard input in BLIND MODE

6. How to read keyboard without blocking ?

7. PerlCRT.dll (was Reading keyboard Input

8. Reading keyboard input

9. Newbie: read a string from keyboard

10. raw keyboard reading and event posting

11. How to read from keyboard without enter?

12. Reading from STDIN pipe & Keyboard

 

 
Powered by phpBB® Forum Software