lua-users home
lua-l archive

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


On Thu, 20 Mar 2014 07:00:12 -0700
Milind Gupta <milind.gupta@gmail.com> wrote:

> Hi,
>       Is it possible to have a non blocking keyboard poll in Lua? If
> there is a keypress I get a key code otherwise I get no key pressed.
> 
> Thanks,
> Milind


=======================================
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
=======================================

SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance