Page 1 of 1

Keyboard input...?

Posted: Mon Oct 01, 2018 8:00 pm
by Gambit37
OK, this one is way beyond my current knowledge and capabilities:

Is it possible to have a full screen renderer that can accept user input via keyboard?

If so, is there anything in the base code that might suggest how to do it?

Re: Keyboard input...?

Posted: Mon Oct 01, 2018 8:27 pm
by Sophia
I'm not sure if it's in the base code but you'll want to use dsb_poll_keyboard in your fullscreen renderer's main loop. It returns nil if the user hasn't pressed a key, or a table containing various information about the pressed key if the user has. The table contains various indices but the two that are most important to you are key which is the pressed key represented as a string, and keycode which is the pressed key represented as an integer.

So if you're using it to let the user type something in, you can store key in a table or concatenate it to a string or whatever you want to do with it.

Code: Select all

rtbl = dsb_poll_keyboard()
mystr = mystr .. rtbl.key

Re: Keyboard input...?

Posted: Tue Oct 02, 2018 9:04 am
by Gambit37
Ah nice, OK, I think that should be enough to get me started. But expect lots of questions about this when I get stuck... :)