SOLVED keyboard_check_pressed(ord("K")) will not return 1 while keyboard_check(ord("S")) returns 1

kpenrose92

Member
Is this an issue that has come up for anyone else? I'm on Windows 10 using GMS version 2.2.5.378

I'm guessing it is Windows-related, because I've tried many other combinations of keyboard_check and they all work fine.
For some reason while the 'S' key is down, gamemaker doesn't recognize the 'K' key.

I've been racking my brain trying to solve this stupid bug. Please let me know if you've found a solution. Thanks!
 

kburkhart84

Firehammer Games
I have a feeling you have run into what they call "ghosting." I may be wrong, as it more commonly happens with keys that are closer together, but you can test in other ways as well...try opening notepad, hold the S down, then hit K a few times at the same time and see if any Ks are in that line of text. You can also test it with other combinations. This will prove if the issue has anything to do with Gamemaker itself or if it is possibly the ghosting that I'm talking about.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Is it intentional that the check for K uses the _pressed variant? This will only register during the first frame of you holding the key down.

If it's intentional: That's likely not GM not recognizing it, but your keyboard not recognizing it. Cheap keyboards often are manufactured in a way that makes it impossible for specific keys to be held down together and still have both of them register. If your keyboard is a cheap low-quality one, this is likely the cause. The opposite of this - absence of such issues - is referred to as n-key rollover (as in, you can press any amount of keys at the same time and they will all register correctly).

You can (roughly) test this by holding down both shift keys and typing the test text "the quick brown fox jumps over the lazy dog" (this contains all standard letters). If the end result of that is anything other than "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG", your keyboard is lacking proper rollover and will therefore fail to register certain keys being pressed together correctly. The only solution in this case is to buy a better keyboard, or to use different keys (for the time being) - preferably make them customizable by the player, so that they do not get hung up on similar issues as you, but with other keys.

Please let me know how the quick brown fox check goes - if this fails, we can be almost certain that the problem is not with your code. If it comes up successful, we may need to take a look at your code as the problem might originate from there after all in that case.
 

kpenrose92

Member
You can (roughly) test this by holding down both shift keys and typing the test text "the quick brown fox jumps over the lazy dog" (this contains all standard letters). If the end result of that is anything other than "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG", your keyboard is lacking proper rollover and will therefore fail to register certain keys being pressed together correctly.
The test went as you predicted - some letters were omitted from the sentence. Amazing, you go your whole life thinking that computer keyboards just worked...
Thanks so much for your help. I'll get to remapping the keys and making them customizable.
 

kburkhart84

Firehammer Games
So it is indeed ghosting...I honestly recommend people have custom controls in their games anyway...this is part of the reason why.
 
Top