Getting keycode from a Keyboard

0 favourites
  • 5 posts
From the Asset Store
Antisuspend Plugin for Construct 3 prevents the runtime from getting suspended.
  • I read a lot of posts about which the keyboard has a specific "key code" for each key pressed. And there's differences between indexing that code for QWERTY/AZERTY keyboards.

    But, my question is ¿How I can get that "code"?

    For example, i want to get the key code of "ctrl" and "p" keys, So that at the moment of pressing them: another event occurs.

    And in c2 to create an event like: if key code is down of "..." & "..." -> something happen.

    Sorry, if my english isn't excellent ~

  • I think this post is useful for you.

    https://www.reddit.com/r/olkb/comments/ ... y_keycode/

  • In addition to shinichild:

    If you simply need the key codes "offline", so not live inside a program, you can create a helper, which shows the key code for the currently pressed button by accessing the expression "Keyboard.LastKeyCode".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure why you need a particular key code.

    Try the following and see if it may help you out:

    1. In your layout, insert new object and choose the keyboard.

    2. In your event sheet, "add event" and choose keyboard. Under Keyboard, select "On Key Pressed" -> "Key". When prompted to choose the key you want, just press the "P" on whatever keyboard you are using and C2 will record that key.

    3. Go back to the same keyboard event in 2 above and "add another condition" and follow the prompts above. When prompted for a key, press the "Ctrl". At this point you will have two conditions that you want met (Ctrl + P) before your chosen action happens.

    4. Then create the action you want to take place.

    Caution: Probably most of the world uses the "QWERTY", but there are many other designs as you have found out and it would be difficult to capture all possible corresponding key codes anyway.

    One solution is to create you own custom controls on the HUD such as sprite arrows. That way, all and sundry will have to use that set of controls as designed by yourself.

    Good luck!

  • shinichild and randomly thank you guys!

    KoolEcky I know, but it's more to learn how the keyboard works, thanks anyways

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