A question about keydown(key_xyz)

BlitzMax Forums/BlitzMax Beginners Area/A question about keydown(key_xyz)

djdee(Posted 2007) [#1]
Hello :)
In a test program i made, it became apparent that some keys seems to cancel out/ block other keys when using the keydown(key_xyz) function.. I noticed hitting leftarrow and space together creates problems in windows, however, it doesnt seem to be a problem in the osx version wich uses the exact same sourcecode. Is there a ways to get around this problem in blitzmax ?? If so, how ?


rdodson41(Posted 2007) [#2]
I've noticed the same problem mostly even on OSX with specifically with the arrow keys and space bar too, I don't think it has to do with BMX but rather the keyboard and os.


djdee(Posted 2007) [#3]
Ok, thats what i suspected.. But aint it pretty lame, taking into account that it is 2007 now...


sswift(Posted 2007) [#4]
This problem has everything to do with the keyboard, and nothing to do with the OS. It was a problem even in the days of DOS when accessing the keyboard directly.

It occurs because of how the circuits are laid out.

Imagine your keyboard is laid out like this:

  1 2 3 
  | | |
a-Q-W-E-
  | | |
b-A-S-D-
  | | |
c-Z-X-C-
  | | |



Now here is what happens if you hold down one key at a time, and keep them held down:

Q = Lines 1,a broken.
W = Lines 1,a,2 broken.
A = Lines 1,a,2,b broken.
S = Lines 1,a,2,b broken.

OOPS! The state did not change when S was held down! All lines that S was connected to were already broken.

So that's the main issue. I couldn't tell you why just space and left arrow would cause a problem though. In theory with this sort of layout you have to hold at least three keys at once before this issue should arise. Even taking into account weird wiring layouts, you still shouldn't have a mere two keys conflicting.

I'd say get a new keyboard, but that won't solve the issue of your users running into this problem. But that's why most games let you configure your keys. And as far as my experience goes, this issue doesn't generally crop up with your standard control schemes on most keyboards.

I suppose it's possible the OS is also doing something to affect this, but if it is that's just sloppy ass programming on their part.


xlsior(Posted 2007) [#5]
But that's why most games let you configure your keys.


It's also why most games started using CTRL and ALT as fire keys instead of the spacebar (which locks up if you press UP and LEFT at the same time, and also when you press DOWN and LEFT)