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.

Well, "a way" encompasses a lot of territory.

I've done it in a variety of ways by writing little C functions callable
from Lua. I've done it using select and read on vxWorks, VMS, and Linux. I've done it by snagging events on Windows. And I've done it on Linux by placing the keyboard in MEDIUMRAW mode, then using select and read.

So yeah, there's "a way", but it requires a bit of C support.
roger ivie