Keyboard Code in Construct 2

3

Attached Files

The following files have been attached to this tutorial:

.capx

Stats

5,847 visits, 7,907 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 12 Jan, 2017. Last updated 19 Feb, 2019

Just before Christmas my teacher friend asked if I could create small application so, that he can find the right keyboard keycode to implement in his game for school project. I have passed the application keyboard keycode to him. Since then I thought why not pass this on for construct 2 user as well. It’s not that hard for Construct 2 user to find their keycode.

Simple let’s start

1. Create new project

2. Set windows size 640 x 480

3. Ste layout size to 640 x 480

4. Set background color as you like

5. Create TEXT title Key Code

6. Create 4 more TEXT and name it as below

7. Create 4 sprite 64 x 64 in any color and name it as below

txtKey_1

txtKey_2

txtKey_3

txtKey_4

spr_Key_1

spr_Key_2

spr_Key_3

spr_Key_4

Add four (4) GLOBAL Variables and name it

Key_1 = 0

Key_2 = 0

Key_3 = 0

Key_4 = 0

To find keyboard character code just press any key on keyboard once. Once you release the key click on 1st colour box to find out key code. Write down key code on paper. Now press 2nd key, as above 2nd colour box do same for 3 and 4. Once you have all the code for mapping key on keyboard use this code to map keyboard.

One thing to remember is you can find out all the 255 character code just by using this code project.

Your screen looks like below:

Let’s add code. Many would say I could have used loop to find code for each key or use keyboard on screen to show you keycode. Well I could but this is very simple method which everyone can understand and learn from it.

Add this code below:

Thank you and if you like it please leave comments, I am not not asking much God bless

.CAPX
  • 0 Comments

Want to leave a comment? Login or Register an account!