Need more flexible keyboard control (Language Help)

by NewM, Wednesday, April 06, 2011, 14:44 (2180 days ago)

I have been looking for a language to help teach my children to program. Basic256 looks perfect.

As a starter, my son wants to write a platform game with me. The problem I have hit is that the Key function:

[*]is not flexible enough to work with key combinations (e.g. hold left-arrow and hit space to run left and jump.)
[*]seems to introduce a delay between the first return and subsequent returns when a key is held down (i.e. just like when you hold down a key in an editor it pauses before repeating).

Is there any way to work around these limitations?


Need more flexible keyboard control

by Jim ⌂ @, Russell, KY, Wednesday, April 06, 2011, 17:24 (2180 days ago) @ NewM

At the present time the "key" function is as good as it gets. Under the hood BASIC256 used QKeyEvent from the QT GUI tool kit. It can not handle multiple key presses.

Let me think about it.

BTW: good for you - showing your son how to get started.


Need more flexible keyboard control

by NewM, Thursday, April 07, 2011, 06:41 (2179 days ago) @ Jim

Hi Jim and thanks for the feedback.

How about a function KeyDown(keycode) that takes an integer parameter specifying the key of interest (same values as returned by Key function) and returns true if the key is down or false otherwise?

If you point me to where the source code is, I could take a look...

Need more flexible keyboard control

by Jim ⌂ @, Russell, KY, Friday, April 08, 2011, 14:09 (2178 days ago) @ NewM

I have looked in the QT toolkit and do not see that functionality, exactly. This question has been around for a long time and has not been resolved, as I can find, See [link=][/link] and Google.

It looks like the key press and release events could be trapped and a global array could be used to keep track of all keystrokes (when a program is running and when one is not) to the UI. The new eventFilter(s) for keyPressEvent/keyReleaseEvent would need to be added to all of the main UI widgets, keep a public array/list, and create a statement to read the array. Sounds like a lot of work. The other solutions on the Web use OS specific functions ad be even more cumbersome, especially since this must work for windoz, LINUX, and OSX.

I'm still thinking.


Need more flexible keyboard control

by NewM, Friday, April 08, 2011, 16:33 (2178 days ago) @ Jim

Yep, I guess that sounds about what I would expect. Thanks for the thoughts...

RSS Feed of thread
powered by my little forum