in reply to Appending keystrokes to a text file

Files can only contain bytes, not keystrokes. So, in addition to finding a method of obtaining the keystrokes (Term::ReadKey?), you need to decide how you want to store them.

Update: I interpreted your question rather literally, but you didn't give us much to go on.

  • Comment on Re: Appending keystrokes to a text file

Replies are listed 'Best First'.
Re^2: Appending keystrokes to a text file
by perlthirst (Scribe) on Dec 16, 2008 at 11:22 UTC

    some work around using Term::Readkey

    It may help for your requirement

    #! /usr/bin/perl use Term::ReadKey; ReadMode 4; # Turn off controls keys open(FH,'>',"file"); $|=1; ## To read 10 characters and write into the file $i=0; ## for reading 10 characters.... while ( $i<10) { until (defined ($key = ReadKey(-1))) {} print FH "$key\n"; $i++; } close FH; ReadMode 0; # Reset tty mode before exiting

      Thank you very much! But what I am looking for is, when this script is running, any keys strokes made in other applications too, for example, I have started this script and type something in notepad, those keys should also be recorded into this file.