Oops accidentally hit post before I finished. What if if wanted code like:
local key, spcl, x, y, button
while true do
key, spcl = console.readchar()
if key then
-- process keypress
x, ,y, button =console.readmouse()
if x then
-- process mouse event
console.readchar will block until a key is pressed and the mouse event won't be checked until then.
- Have readchar and readmouse take a boolean argument indicating whether blocking or non-blocking behavior is desired.
- Add a function console.readevent which waits for either a key press or a mouse event, this would return
"key", key, special or
"mouse" , x , y, button
In the first case, the non-blocking read would return nil if no event has occurred. The second case could be eventually expanded to other events such as resizing the console.