This queue is for tickets about the TermReadKey CPAN distribution.

Report information
The Basics
Id:
27944
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
tyemq [...] cpan.org
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
2.30
Fixed in:
(no value)



Subject: Win32: ReadKey(0) ignores Enter
On Win32, in 'raw' mode, ReadKey(0) just ignores the Enter key. The work-around is to use a really long delay rather than an infinite one, for example, ReadKey(~0/2-1), which causes Enter to be returned as "\r". So the fix is probably to move the call to PeekConsoleInput() from line 1571 of ReadKey.xs to be outside of the if() block: PeekConsoleInput(whnd, &record, 1, &readRecords); if (delay != 0) { if (readRecords == 0) return(FALSE); } or, more likely: PeekConsoleInput(whnd, &record, 1, &readRecords); if (delay != 0 && readRecords == 0) return(FALSE); } No, I haven't spent much time trying to figure out why that appears to make a difference. It might be worth noting in the documentation that, depending on platform and settings, the Enter key may be returns as "\r" or "\n" (either can happen on Unix, there being a setting specifically for that translation), so that more portable code is likely produced.
On Tue Jul 03 12:29:08 2007, TYEMQ wrote:
Show quoted text
> On Win32, in 'raw' mode, ReadKey(0) just ignores the Enter key. The > work-around is to use a really long delay rather than an infinite one, > for example, ReadKey(~0/2-1), which causes Enter to be returned as "\r". > > So the fix is probably to move the call to PeekConsoleInput() from line > 1571 of ReadKey.xs to be outside of the if() block: > > PeekConsoleInput(whnd, &record, 1, &readRecords); > if (delay != 0) { > if (readRecords == 0) > return(FALSE); > } > > or, more likely: > > PeekConsoleInput(whnd, &record, 1, &readRecords); > if (delay != 0 && readRecords == 0) > return(FALSE); > } > > No, I haven't spent much time trying to figure out why that appears to > make a difference. > > It might be worth noting in the documentation that, depending on > platform and settings, the Enter key may be returns as "\r" or "\n" > (either can happen on Unix, there being a setting specifically for that > translation), so that more portable code is likely produced.
If this is still an issue please could you submit a patch against https://github.com/jonathanstowe/TermReadKey cheers!


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.