1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Windows Keyboard arrow check bug

Discussion in 'Programming' started by Aaron Craig, Oct 28, 2017.

Tags:
  1. Aaron Craig

    Aaron Craig Member

    Joined:
    Jun 20, 2016
    Posts:
    31
    Greetings.
    I believe there's a small bug when checking the arrow keys and the spacebar (spacebar appears to be the worst culprit, though I've tried other keys and they have problems, too). I've got this code inside of an object:

    if(keyboard_check(vk_right))
    x += 15;
    if(keyboard_check(vk_left))
    x -= 15;
    if(keyboard_check(vk_up))
    y -= 15;
    if(keyboard_check(vk_down))
    y += 15;
    if(keyboard_check(vk_space))
    show_message("fire");

    And when I hold any combination except up and right, spacebar doesn't trigger. I've tried it in separate events for each key, I've tried beginning and end steps, I've tried different projects, different logins, but it always doesn't work.
    If I switch it to WASD movement, then it does. This makes me think it's something specific with the arrow keys and the way gamemaker handles them being pushed down.
    I have even set the movement to WASD, gotten spacebar to work properly, then mapped the arrow keys to WASD and tried it, and it doesn't work. It's something specific about the arrow keys being pushed down.

    I don't think I'm overlooking anything obvious, but if I am please point it out.
     
  2. Carnivius

    Carnivius Member

    Joined:
    Jun 20, 2016
    Posts:
    168
    Not a Game Maker bug. It's a keyboard limitation.
    Easy work around is don't use Space with cursor keys. Most folks use Z or X or other keys in that area as an action key instead.
     
    ParodyKnaveBob likes this.
  3. Aaron Craig

    Aaron Craig Member

    Joined:
    Jun 20, 2016
    Posts:
    31
    Good to know. Annoying, but I guess I'll deal with it. Thanks.
     
    ParodyKnaveBob and Carnivius like this.
  4. Carnivius

    Carnivius Member

    Joined:
    Jun 20, 2016
    Posts:
    168
    is ok. Also keys like Ctrl, Alt and Shift are usually exempt from the limitation because they are designed as standard to be held down with other keys but some players like myself find them a bit awkward (especially with the Windows key between ctrl and alt which can be accidentally pressed and be annoying) :p
     

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