lua-users home
lua-l archive

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

On Thu, 20 Mar 2014 16:15:16 +0200
steve donovan <> wrote:

> On Thu, Mar 20, 2014 at 4:08 PM, Steve Litt
> <> wrote:
> > function getch_unix()
> >         os.execute("stty cbreak </dev/tty >/dev/tty 2>&1")
> >         local key =
> >         os.execute("stty -cbreak </dev/tty >/dev/tty 2>&1");
> >         return(key);
> > end
> That is indeed ingenious! 

Isn't that brilliant (Litt puffs out his chest).

I'd like to thank the guys who documented it, last century. You can see
it by:

man perlfunc

Then search for getc, and you'll see where I learned about it, back in

But of course, I'm taking complete credit for it :-)

Since then, I've used this same technique to read a single character,
sans newline, in Perl, Python, Ruby, Lua, and maybe even Bash and maybe

Reading a keyhit without requiring a following Enter is a core
requirement for my UMENU software, which I've written in Perl, Python,
Ruby and Lua.

That getch_unix() I posted was copied and pasted out of the Lua
version of UMENU.

I love computers.



Steve Litt                *
Troubleshooting Training  *  Human Performance