[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Check for a keypress
- From: "David Hamill" <david@...>
- Date: Sat, 30 Nov 2013 18:11:24 -0000
On Fri, 29 Nov 2013, Jose Torre-Bueno wrote:
Is there a way from inside Lua to check whether any key has been
pressed? io.read() will get a line from the console but if there
is no input it pends waiting for input. I would like to be able
to write a test that gets input if any is ready but would continue
if there is none. It is not obvious to me if this can be done at all.
Because this depends on the keyboard hardware (Apple/Windows/Linux, number
of keys, layout, country etc)and also on how the OS handles the keyboard at
a low level (buffering, key code mapping etc), there's unlikely to be a
single solution that will work across all platforms.
For a single platform, the best solution is probably to revert to C and make
the relevant API calls.