Can anyone tell me how I would capture a non-printable character from STDIN and test what the character is? Specifically, I want to test if the escape key has been pressed.
See Term::ReadKey:
use warnings; use strict; use Term::ReadKey qw/ReadMode ReadKey/; use Data::Dumper; $Data::Dumper::Useqq=1; print "Press a key\n"; ReadMode 'cbreak'; my $key = ReadKey(0); ReadMode 'restore'; print Dumper($key); if ( $key eq "\e" ) { print "Escape pressed\n"; }
Trying to build a console based text editor.
Beware of reinventing the wheel, but anyway, see Curses and perhaps Curses::UI (though the latter is pretty old by now).
In reply to Re: Capture a non-printable char and test what it is
by haukex
in thread Capture a non-printable char and test what it is
by almsdealer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |