[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Reading one key from stdin without waiting for return
- From: Perry Smith <pedz@...>
- Date: Tue, 2 Aug 2022 19:13:28 -0500
> On Aug 2, 2022, at 18:32, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
>
> See http://lua-users.org/lists/lua-l/2012-09/msg00352.html
Luciano,
As Luis suggests, the data is being buffered in the tty driver down in the OS until you hit the return key. Then the tty driver sends the line up to the process. The process reads one character as you have instructed it.
This is called “cooked” mode in old BSD parlance. What you want is “raw” mode. Depending upon the underlying OS, this is done by different means. As the original author warns, the tty mode should be saved first and then restored. And, also as he says, this may not work on the OS you are using. e.g. in particular, I have no idea how to do these things on Windows.
Good luck,
Perry
Attachment:
signature.asc
Description: Message signed with OpenPGP