If we implemented a cross-platform “keypressed”, might there be
any chance of it getting into the builtin library?
A frequent beginner C/C++ FAQ is the one above. It seems like a
high-level language such as ruby should be able to give a good
solution to it, rather than a lengthy answer involving Win32 API
or Termios witchery.
select[[$stdin], nil, nil]
if key_pressed() does not allow mixing with select(), it lost its
disclaimer: unlikely to work on Win*
^ There’s the problem. Surely something could be worked out for
Windows, too. However, expecting individual programmers to
reinvent those wheels is a violation of the DRY principle.
I think it would be handy to have key_pressed, or preferably
"getch", as a part of the standard library.
I could be wrong, though.
I think I’m generally in favor of this kind of thing,
but I’d like it to be isolated in some kind of “OS-
It’s likely to be implemented differently on every
different OS, not just Win and *nix.
I’m not sure how much of that it’s appropriate to reveal
to the coder and how much to conceal.
The old fork() that worked under Cygwin is a case in point.
Should we have a fork() on Win32 that perhaps calls
CreateProcess? Or should we just not even pretend that
Win is anything like *nix? Many of the file operations
work transparently between the two. Where do you draw
----- Original Message -----
From: “Ryan King” firstname.lastname@example.org
To: “ruby-talk ML” email@example.com
Sent: Tuesday, September 10, 2002 4:14 PM
Subject: Re: Equivalent of pascal’s keypressed ?
On 2002.09.11, Kero van Gelder firstname.lastname@example.org wrote: