Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

How to ReadKey on those weird ones...

by PipTigger (Friar)
on Jul 09, 2000 at 13:33 UTC ( #21691=perlquestion: print w/ replies, xml ) Need Help??
PipTigger has asked for the wisdom of the Perl Monks concerning the following question:

I've tried to use Term::ReadKey to get a single key and I have the latest one installed but I get a segfault everytime I try to ChangeMode... so I found HotKey.pm which serves my text character input needs fine... but how does one go about reading special characters like Controls and Alts and Arrow keys etc.? Please help! Thanks. TTFN.

-PipTigger
p.s. the most cigarettes

Comment on How to ReadKey on those weird ones...
Re: How to ReadKey on those weird ones...
by Aighearach on Jul 09, 2000 at 18:27 UTC
    You can use to Term::ReadKey to read raw keystrokes. The follow code prints out an interger value coresponding to each keystroke. While it doesn't let you check the conrol keys without another key, it does let you tell the difference between control+key, and alt+key, or to detect the arrow keys.

    The following code tested under linux. If you are using another platform, be sure to RTM first.

    Note also that if you run this code, you will have to kill the process remotely. If that doesn't make any sense, change ReadMode before you run it.

    use strict; use Term::ReadKey; ReadMode 5; while (my $key = ReadKey(0)){ print ord($key) } ReadMode 0;

    update: have you tried rebuilding and/or reinstalling Term::ReadKey? It is a very important module, I would focus on getting it to work instead of replacing it.

    Is it any call to ReadMode that crashes?

    If you install via perl -MCPAN -e'shell' then it will do a number of tests as it installs.

    Paris Sinclair    |    4a75737420416e6f74686572
    pariss@efn.org    |    205065726c204861636b6572
    I wear my Geek Code on my finger.
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://21691]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-08-29 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (286 votes), past polls