lua-users home
lua-l archive

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


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