From: Ryan King Date: 2002-09-11T06:14:53+09:00 Subject: Re: Equivalent of pascal's keypressed ? On 2002.09.11, Kero van Gelder wrote: > > 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 efficiency. > > 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. - Ryan King