[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Reading one key from stdin without waiting for return
- From: Luciano de Souza <lucsouza1975@...>
- Date: Tue, 2 Aug 2022 20:25:41 -0300
Hello all,
Observe this code:
print('Press any key:')
key = io.read(1)
print('The pressed key was ' .. key)
The user informs 5 and press return. 5 is printed on screen.
If user informs 51, as only one byte is read, 5 is printed anyway.
But this is not the behaviour I wanted.
I's like not to press return. In other words, I'd like to start a loop.
When a key was pressed, it would be return imediately without waiting
for the next pressed key.
How to obtain this effect with Lua?
I thank you very much for any help.
Best regards,
Luciano de Souza