Keydown

BlitzMax Forums/BlitzMax Programming/Keydown

*(Posted 2008) [#1]
Is it me or is keydown temperamental?

My testers tell me sometimes it works 100% others it doesnt.


Perturbatio(Posted 2008) [#2]
I've never seen a problem with it myself, could it be keyboard related?


GfK(Posted 2008) [#3]
could be, if they're trying to hold down multiple keys at once and one isn't registering.


Dreamora(Posted 2008) [#4]
keydown should always work.
It uses the OS API keydown event to set the array slot of the key to true and keyrelease / keyup to set it to false.
the only thing interfering here would be eventhooks and especially the use of flushkeys within a such.

But as a educated guess: you aren't using the arrow keys for control, are you?
because they are restricted to the amount of keys beeing pressed at the same time. up + left/ up + right or the same to down normally does not work and will result in one key beeing ignored. thats a keyboard "issue" due to the way the keyboard is partitioned into areas that use the same line to send their state data


*(Posted 2008) [#5]
im using A, Z, S, X, N and M.

Yes multiple keys are being pressed as this is for an Elite game that uses them for a flight model. Ive never had this problem with Blitz3d as the code is a direct port from that to Max and its only on max it has the trouble.


Panno(Posted 2008) [#6]
maybe a keyboard problem .
try a better one


Perturbatio(Posted 2008) [#7]
Can you add an alternative set of keys that would, if necessary, allow them to use some keys on the left and some on the right of the keyboard?


Dreamora(Posted 2008) [#8]
Well "multiple" is fine
More than 3 parallel thought most likely not. cherry keyboards have their max somewhere between 3 and 4.

No Prob in Blitz3d most likely, its direct input, that has some tricks. But one in BM that is crossplatform and as OSX and Linux are crap when it cames to game input devices, BM is forced to use something that works on those as well instead of DI


Trader3564(Posted 2008) [#9]
I know this issue. Some keyboards, or system configurations, whatever, cause to block when more then X yes are pressed. in my case on one keyboards i can only press 4 keys at a time or it will beep and block.


impixi(Posted 2008) [#10]
I've experienced the same as Goldstar. Some systems can detect less simultaneous keypresses than others.

Incidentally, there’s a post by Mark in this topic, that I found useful regarding input handling. Specifically:

marksibly:

Currently, Max assumes your app is running in either 'polled' or in 'event driven' mode - although users have mixed the 2 with varying degrees of success...

The idea here was that in polled apps, users wouldn't have to worry about PollSystem - it would be automatically handled whenever user input is queried (KeyDown, AppTerminate etc).

Event drivens apps on the other hand would get full control of when PollSystem occured, via PollSystem, WaitSystem, PollEvent or WaitEvent - and I like this degree of certainty.



Once I changed my framework to be fully dependent on ‘event driven mode’ (as opposed to mixing ‘polled’ and ‘event driven’), all the glitches I was experiencing vanished. (Though you’ll still be limited by a maximum number of simultaneous keypresses on a per system basis).


jhans0n(Posted 2008) [#11]
Key masking and key ghosting is a pretty common issue. Basically, if you hold down three keys, it can prevent a 4th one from registering. Or, it can sometimes cause a phantom key press, resulting in it appearing like a 4th key was pressed when it wasn't. This is because keyboards use a matrix system, and it varies from keyboard to keyboard.

Google "keyboard matrix" for more info.


*(Posted 2008) [#12]
will have a look :D


Matt Merkulov(Posted 2008) [#13]
Btw, are there keyborads (USB or wireless for example) that can handle presses of 4 keys and more at one time (to play several people on one computer simultaneously)?


xlsior(Posted 2008) [#14]
My testers tell me sometimes it works 100% others it doesnt.


Most keyboards have certain lock-out combinations, due to their design (multiple keys sharing the same circuit paths, if you have more than a certain number of hits it will block out the others)

for example: if you have the "UP" cursor key down, it will detect either "RIGHT" or "LEFT" at the same time, but it won't see UP and RIGHT and LEFT.

This is one of the main reasons many games started using the control, alt and shift keys to shoot -- the modifier keys always work and don't block any other keys in the process.


*(Posted 2008) [#15]
fixed it, it was a timing issue