1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Windows More than 3 keys pressed

Discussion in 'Programming' started by Chaser, Nov 7, 2019.

  1. Chaser

    Chaser Member

    Joined:
    Jul 29, 2016
    Posts:
    120
    Hi, having a few issues with keyboard_check events.

    I'm asking GMS2 to check if there are three keys pressed at the same time.

    if key_down && key_right && key_punch
    {
    change state
    }

    However this is not working.
    So i tried

    if key_down && key_right
    {
    if key_punch
    {
    change state
    }
    }

    This is not working either.

    So i tested just using two key presses

    if key_down && key_punch
    {
    change state
    }

    This works fine, So GMS2 recognises two buttons pressed at the same time but not three.
    I have been told that GMS2 or Windows won't allow you to do more than three key presses at the same time unless you do something somewhere, change a setting, or it depends on what keyboard you are using. it's a little confusing and i'm not sure where to turn to at this point, so I'm hoping one of you guys could point me in the right direction, or enlighten me on how i should approach three button commands. :)
     
  2. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,646
    It'
    It's probably keyboard ghosting causing you the issue, which you can test for somewhere like here: https://drakeirving.github.io/MultiKeyDisplay/
    if you use a different set of keys (or different 3rd key) it will likely work, but whether that is a good combination for input to your game is another matter.
     
    Chaser likes this.
  3. Chaser

    Chaser Member

    Joined:
    Jul 29, 2016
    Posts:
    120
    Thanks @rIKmAN

    I changed some of the keyboard keys and its working now, not sure its ideal for what i want, but i can work with it at least, and its not a bad code from myself.

    Just for reference in case someone else comes across the same thing i did, didn't find anything in the GM help files.

    I was using the 'Arrow Keys' for movement and the 'Num Keys' for actions, this works OK, 2 button checks are OK, but when you move to a third this isn't going to work. There are certain key combinations you cannot use, but this is dependant on the keyboard type you are using and NOT GMS. It's difficult to say what these 'Combinations' are without checking every possibility. What i can say is 'Space' bar cannot be used as a 3 button press check whilst using the arrow keys, or more than one of the 'Num Keys' as mentioned above, but using the 'Letter' keys can be used in combination with the arrow keys. :)

    I would say if your planning on using more than 2 key 'combos' in your project then do not use the arrow keys as your movement input, stick with the good old "A,W,S,D" or "Q,A,O,P, Space' (old skool!) just to be safe.
    A lot of you probably knew this already, but i didn't!, so for those that didn't like me, hopefully you will find this helpful.

    Feel free to add here what combinations that use more then 2 combos that didn't work for you.
     
    rIKmAN likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice