'Better than having sex with a noob'
AS: KeyCode
So all of you know how to check if Space or Enter is pressed, by simply applying the following code:
if(Key.isDown(Key.SPACE))
But you have always wondered how to use WASD and 1 2 3. That's why I'm making this tutorial. It will teach you how to use different keys for your games, better than up down left right.
KeyCodes: How to use?
This is very simple and alike to other keys. Simply use:
if(Key.isDown(<keycode here>))
What are the keycodes?
Numbers
The following keycode are codes you need to use for all the numbers appearing on your keyboard: 1,2,3,4,5,6,7,8,9,0.
1 = 49.
2 = 50.
3 = 51.
4 = 52.
5 = 53.
6 = 54.
7 = 55.
8 = 56.
9 = 57.
0 = 58.
Example:
if(Key.isDown(50)){
trace("Yay!");
}
That would trace 'yay' if the key '2' is pressed.
KeyCodes: Alphabet
Now this is very simple, just like the numbers every letter of the alphabet has its own code.
a = 65
b = 66
c = 67
d = 68
e = 69
f = 70
g = 71
h = 72
i = 73
j = 74
k = 75
l = 76
m = 77
n = 78
o = 79
p = 80
q = 81
r = 82
s = 83
t = 84
u = 85
v = 86
w = 87
x = 88
y = 89
z = 90
Example:
if(Key.isDown(65)){
trace("You pressed 'A' ");
}
Output for if you press A:
You pressed 'A'
That's it, you're done.
Have a nice day.
-Toast.
Bai.