How do I LIMIT KEYBOARD INPUT

Get help using Construct 2

Post » Sat Dec 10, 2016 1:33 pm

I see the "On ANY key pressed" in the keyboards event. How can I limit it to react only if an alphabetical char (A TO Z) is pressed?
I'd like not to have multiple events like:
On KEY PRESSED "A"
On KEY PRESSED "B"
On KEY PRESSED "C"
On KEY PRESSED "D"
and so on.....

Is there a way?
Thank you!
B
12
S
5
Posts: 42
Reputation: 990

Post » Sat Dec 10, 2016 1:47 pm

I found way (maybe not the best.
I have a global var "ABCDEFGHI.....Z" and I compare if the valuef from the keyboard is inside this var with find(Variable, Keyboard.StringFromKeyCode(Keyboard.LastKeyCode))
B
12
S
5
Posts: 42
Reputation: 990

Post » Sat Dec 10, 2016 7:52 pm

There should be an "on key pressed" option, which allows you to pick ANY key.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Tue Dec 13, 2016 12:06 pm

"On key pressed" asks you wich key shold be pressed to fire an action.
So one should do:
"On key pressed A"
"On key pressed B"
"On key pressed C"
and so on...
B
12
S
5
Posts: 42
Reputation: 990

Post » Tue Dec 13, 2016 12:23 pm

You did right, also, you can use dictionary instead of global variable.
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817

Post » Tue Dec 13, 2016 12:32 pm

@Ciao121

You could use ascii-codes:

Keyboard | On any key pressed
System | 65≤ Keyboard.LastLeyCode≤90 -> Do something.
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Tue Dec 13, 2016 4:07 pm

Asmodean wrote:@Ciao121

You could use ascii-codes:

Keyboard | On any key pressed
System | 65≤ Keyboard.LastLeyCode≤90 -> Do something.


Thank you; I thinked about it. But I preferred my solution becaouse it was easier "to read" in the code.
B
12
S
5
Posts: 42
Reputation: 990


Return to How do I....?

Who is online

Users browsing this forum: batto and 20 guests