KeyDown
Monkey Forums/Monkey Programming/KeyDown
| ||
Hi, guys! So, this is the code: Local teclas:Bool=False Local L:Int=KeyDown(KEY_LEFT),R:Int=KeyDown(KEY_RIGHT) If L=1 And R=1 Then teclas=True If I press first KEY_LEFT / KEY_RIGHT then I press KEY_RIGHT / KEY_LEFT, locals 'L' and 'R' return 1, but if I press another key with then, the second local won't return 1. I don't know if I could make myself clear, but does anyone know why that behavior? |
| ||
Yeah , it might be a bug but I suspect its the Keyboard Drivers, for me when I test this and press UP Arrow and then the Left and Right arrow keys it returns false, but if I press Down Arrow first and then the left and right together ( having all three down at the same time ) it works. |
| ||
Ok, thanks, Paul. I hope Mark sees this and give us an straight answer. |
| ||
I threw it into the debug section just in case it is a bug but I think its just poor keyboard drivers. I have this issue now with my crappy keyboard but when I was rocking my G16 possibly the best keyboard in the world (until I dropped my cola all over it) I never had the issue. |
| ||
Older keyboard? PS/2 port? Some are sketchy with multiple simultaneous presses. |
| ||
Even newer keyboards have this problem. It's called "key ghosting" - some keys won't register when pressing multiple keys at the same time. That is the reason for some games using WASD as movement keys, because there is no "ghosting" effect with those. More on the subject: https://www.microsoft.com/appliedsciences/antighostingexplained.mspx |
| ||
I can confirm that this is not a bug with monkey present in 84a using mojo or mojo2. (using a keyboard with n-key rollover) It's worth noting that this isn't a drivers issue, it is an issue present with any usb keyboard. I've even heard of manufacturers who sell high-end keyboards causing multiple keypresses among WASD to be unreported in their cheaper models. |
| ||
Not only USB keyboards - this was always a problem, since the keyboard was invented :) Even PC-XT and other machines (like MSX, ZX Spectrum, etc) have this problem. Of course, some cheap-o keyboards will have it even worse, but the problem exists on every keyboard, one way or another. |
| ||
I remember encountering this issue on the Spectrum! |
| ||
Yeah, an age old issue.. This is why you'll find games using cursors and Z or X.. Using spacebar along with cursors seems to make this issue much worse! In the majority of gameplay cases, the player won't be using more than 2 cursor keys at once, so this issue isn't really as bad as it seems, as long as you're coupling that with Z/X or anything other than that bloomin' spacebar! Ctrl and Shift also occasionally cause issues, depending on the keyboard. |