lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Fri, 29 Nov 2013, Jose Torre-Bueno wrote:
Is there a way from inside Lua to check whether any key has been
pressed? 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.