#!/usr/bin/perl use Term::ReadKey; use Time::HiRes qw(time); ReadMode 3; # 'noecho'; while (1) { my $key; my $wait_until = time + 3; while ( time < $wait_until ) { $key = ReadKey( -1 ); if ( defined $key ) { print STDERR "keystroke $key\t"; } } print "Something\n"; }