in reply to Reading all nonblocking keystrokes in Win2000

Having finally found a Win32 system, I tried this and you're right. You can tell IF one of these keys is pressed but not which one. If the return is truly undef, then nothing was pressed, if it's a null byte (ord($c)==0 and length $c) then one of these other keys was pressed.

The Win32PeekChar routine is an XS routine, it interfaces C and Perl. Looking at the module's source it doesn't look like its at all equipped to give a multibyte return value -- so you're screwed. The Win32 API calls used (PeekConsoleInput, ReadConsoleInput, WaitForSingleObject) might provide the raw information to Win32PeekChar but I'm not going to research the Win32 API for someone else's question. I'm not a masochist. :)

It is possible to do this because the Tk module can catch these kinds of events. But Tk is a hefty beast if all you want is to catch keystrokes. Perhaps brush up on your C programming and fix ReadKey.xs to do the Right Thing.

  • Comment on Re: Reading all nonblocking keystrokes in Win2000