Check out Term::ReadKey. Its synopsis almost exactly shows what you want.
In reply to Re: how to check for keyboard input by Tanktalus in thread how to check for keyboard input by redss