in reply to Stuff the keyboard buffer

You might want to check out the module Term::ReadKey. I haven't used it myself though but it seems like one way to do it. ;-)