in reply to Re: Reading keyboard input without focus
in thread Reading keyboard input without focus
Using the commented line of Input, the program works as expected and only accepts input when in focus. Using PeekInput will work if you type something while in focus, but only if you haven't typed something in another window after starting the program.use Win32::Console; $StdIn = new Win32::Console(STD_INPUT_HANDLE); my $key; while (!(defined @event)) { @event = $StdIn->PeekInput(); #@event = $StdIn->Input(); $key = chr($event[5]); } print join(" ", @event),"\n"; print "Got key $key!\n";
|
|---|