Washizu has asked for the wisdom of the Perl Monks concerning the following question:
My problem:
I would like to have a module that can check to see if the user is pressing keys at any time, and what keys are being pressed. I don't want to have to wait for a carriage return.
My failed solution:
#!/usr/local/bin/perl5 # Use Perl 5 use Term::ReadKey; my $c = ""; ReadMode(5); while ($c ne "q") # Press q to exit { $c = ReadKey(-1); if ($c ne "") { print $c; } } ReadMode(0);
Why it Fails:
Although it returns characters, numbers, and symbols just fine, it returns something strange on other keyboard input, such as the delete key, arrow keys, insert, home, etc. In the terminal it looks like a space, but it is something else. I know this because when I test for " ", it doesn't equate.
Question:
How can I get the keystrokes I'm looking for?
-----------------------------------
Washizu
The best offense is a good offense.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading all nonblocking keystrokes in Win2000
by clintp (Curate) on Nov 16, 2001 at 05:22 UTC | |
by Washizu (Scribe) on Nov 16, 2001 at 08:39 UTC | |
by clintp (Curate) on Nov 16, 2001 at 09:47 UTC | |
by Washizu (Scribe) on Nov 16, 2001 at 18:17 UTC | |
by tye (Sage) on Nov 19, 2001 at 21:27 UTC | |
| |
|
Re: Reading all nonblocking keystrokes in Win2000
by c-era (Curate) on Nov 16, 2001 at 00:35 UTC | |
by Washizu (Scribe) on Nov 16, 2001 at 01:38 UTC | |
|
Re: Reading all nonblocking keystrokes in Win2000
by clintp (Curate) on Nov 16, 2001 at 21:50 UTC |