I tried using the functions defined in Term::ReadKey.
The readkey function returns keyboard events that occur while the application is still in focus. When the user brings another program into focus Readkey is unable to return key evens. I'm looking for something like windows GetKeyboardState ().