in reply to howto capture a keystroke
The following works great in windows. Shows you what the keyboard produced, exits when you hit ENTER. Note that some keys (like arrows) produce multi-character sequences.
#!/usr/bin/perl -w use strict; use Term::ReadKey; my $key; my $OrdKey; ReadMode 'raw'; do { $key = ReadKey(0); $OrdKey = ord($key); print "Key is $OrdKey\n"; } while ($OrdKey != 13); ReadMode 'restore';
|
|---|