I have written a game where the movement of an object is controlled by four Keyboard.AsynckeyDown commands in a timer. Owing to differences in OS and international keyboard standards, I need to be able to let the user decide which key presses to use in the game but I can find no way to interogate a user’s test key press and turn it into a Keyboard.AsynckeyDown number. All help greatly appreciated.
for i as integer=0 to 127 if Keyboard.AsynckeyDown(i)
You have to define a way to let the user define the keys (e.g. in a preferences window) and reuse the same in the timer.
The only thing the timer knows about the keyboard is the key codes. Therefore, you also have to know and store the key codes when the user enters the keys (s)he wants.
With Markus’ code above, you’ll have to loop from 0 to 127 when the user defines a key, like in a KeyDown event (that’s so fast that you’ll catch the keys) and store the value of the variable when the call returns true (the key(i) is down).
That’s one simple way to do it.
Excellent. Thanks you both for your advice. That works perfectly.
You’re welcome. Glad it suits your needs.