#!/usr/bin/perl use Term::ReadKey; #passing ReadKey() an argument of -1 to indicate not to block: ReadMode('cbreak'); while(1){ my $char; if (defined ($char = ReadKey(0)) ) { print "$char->", ord($char),"\n"; # input was waiting and it was $char } else { # no input was waiting } } ReadMode('normal'); # restore normal tty settings