lua-users home
lua-l archive

Re: Non blocking user input

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


On 2014年3月20日 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

AltStyle によって変換されたページ (->オリジナル) /