This queue is for tickets about the TermReadKey CPAN distribution.

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

People
Owner:
Nobody in particular
Requestors:
bart.lateur [...] pandora.be
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
2.14
Fixed in:
(no value)



Subject: Workaround to not to have to press "enter" twice for ReadKey() under Windows
If you do the following thing under Windows: use Term::ReadKey; ReadMode 3; # or 4, or 5 ReadKey 0; ReadMode 0; This will wait for you to press one normal key, before continuing... except for the "enter" key, which you have to press twice. It works normally (= as any other key) on Linux. I guessed that this might be related to the CR+LF -> LF foo on Windows, so I tried to use binmode(): use Term::ReadKey; binmode STDIN; ReadMode 3; # or 4, or 5 ReadKey 0; ReadMode 0; and lo! It works! So I likely must have guessed right. IMO this either should be documented in the docs, or maybe a (transparent) workaround be coded in the module. n.b. ReadKey() returns chr(13) ("\r") for <enter>. That might be patched, too, as Perl on Windows prefers "\n".
[guest - Wed Sep 17 10:02:22 2003]:
Show quoted text
> If you do the following thing under Windows: > > use Term::ReadKey; > ReadMode 3; # or 4, or 5 > ReadKey 0; > ReadMode 0; > > This will wait for you to press one normal key, before continuing... > except for the "enter" key, which you have to press twice. It works > normally (= as any other key) on Linux. > > I guessed that this might be related to the CR+LF -> LF foo on > Windows, so I tried to use binmode(): > > use Term::ReadKey; > binmode STDIN; > ReadMode 3; # or 4, or 5 > ReadKey 0; > ReadMode 0; > > and lo! It works! So I likely must have guessed right. > > IMO this either should be documented in the docs, or maybe a > (transparent) workaround be coded in the module. > > n.b. ReadKey() returns chr(13) ("\r") for <enter>. That might be > patched, too, as Perl on Windows prefers "\n".
Thanks for this. I am going to make a release for Term::ReadKey in the near future and will include these. /J\


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.