|
On Mar 20, 2014 2:16 PM, "steve donovan" <steve.j.donovan@gmail.com> wrote:
>
> On Thu, Mar 20, 2014 at 4:08 PM, Steve Litt <slitt@troubleshooters.com> wrote:
> > function getch_unix()
> > os.execute("stty cbreak </dev/tty >/dev/tty 2>&1")
> > local key = io.read(1)
> > os.execute("stty -cbreak </dev/tty >/dev/tty 2>&1");
> > return(key);
> > end
>
> That is indeed ingenious! I was about to suggest using luaposix and use select.
>
> The point is that there's no platform-independent way of doing this....
>
> For Windows, you can get async i/o on the console using winapi:
>
> http://stevedonovan.github.io/winapi/api.html#get_console
>
> This returns a File object which has a read_async method, which you
> pass a callback to receive anything read.
>
For Linux you can also use the /dev/input API if you want actual raw keypress and mouse data.
Justin