How do I detect keyboard keycode 97?

0 favourites
  • 7 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • So, I'm trying to test whether Construct 2 can detect the keycode for both "A" and "a", turns out Construct can only detect keycode 65 (for "A") and not 97 (for "a") because the debug text object doesn't show anything when I use event On keyboard key code 97 pressed.

    Does anyone know how do I detect "a" keycode? Because I want to do something different when the keycode for "A" and "a" are pressed.

    thanks.

  • It's the same key on the keyboard, so the keycode would be the same. I guess you could also check if shift held down.

    Here is a list of the keycodes reported by javascript, which C2 uses:

    http://www.cambiaresearch.com/articles/ ... -key-codes

    97 is Numpad 1 in that list.

    I think what you wanted was the charCode which could give you a 97 for "a", but the keyboard object doesn't provide that.

  • So, I'm trying to test whether Construct 2 can detect the keycode for both "A" and "a", turns out Construct can only detect keycode 65 (for "A") and not 97 (for "a") because the debug text object doesn't show anything when I use event On keyboard key code 97 pressed.

    Does anyone know how do I detect "a" keycode? Because I want to do something different when the keycode for "A" and "a" are pressed.

    thanks.

    Not sure why Keyboard.LastKeyCode doesn't return full ASCII codes. Maybe Ashley can clarify.

    Since all lower case letters are equal to the keycode for the uppercase + 32, you could do it in Events.

    For instance,

    IF SHIFT (or CAPS) IS DOWN set keyvariable to Keyboard.LastKeyCode+32

    ELSE set keyvariable Keyboard.LastKeyCode

    Would this be of use?

  • R0J0hound : yes, I think you're right, it's charCode that I want. I just didn't remember it, if only I can get charCode for C2

    zenox98 : I haven't tried that, I tried this

    Keyboard On A pressed AND keyboard Shift is down | Do action here

    but then both this event and the event without shift is down are triggered, so I didn't use it.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Keyboard On A pressed AND keyboard Shift is down | Do action here

    but then both this event and the event without shift is down are triggered, so I didn't use it.

    So adding a shift is NOT down to the first event would prevent that, right?

  • You can use the browser object to get the charcode instead of the keycode. It can't be a trigger, so instead a list of keys pressed that tick is made and looped over.

    https://dl.dropboxusercontent.com/u/542 ... rcode.capx

  • : ah,of course. How come I didn't see the obvious fix??

    R0J0hound: I'll try that capx, hopefully it's good enough. thanks.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)