Or use a bidimensional array which stores the status of each key you need.
Suppose you want to chek for the key code 57, 15 and 21 (57 should be space bar, I don't recall now, the rest are examples but you should get the drift).
That are 3 keys to be tested, right ? So we can use a bidimensional array of three elements:
the first value is the keycode, the second is the status.
So, at the beginning we can set up the array:
Note that I ignore the ak(0) element here, you can optimize it if you like.
Now, we can test for the key pressed and depressed:
Hope this has sense for you,
Sergio.
Suppose you want to chek for the key code 57, 15 and 21 (57 should be space bar, I don't recall now, the rest are examples but you should get the drift).
That are 3 keys to be tested, right ? So we can use a bidimensional array of three elements:
dim ak(3,2)
the first value is the keycode, the second is the status.
So, at the beginning we can set up the array:
ak(1,1) = 57 ;the key code ak(1,2) = 0 ;status: depressed ak(2,1) = 15 ;the key code ak(2,2) = 0 ;status: depressed ak(3,1) = 21 ;the key code ak(3,2) = 0 ;status: depressed
Note that I ignore the ak(0) element here, you can optimize it if you like.
Now, we can test for the key pressed and depressed:
for n = 1 to 3 ;where 3 is the total number of keys to be tested if keydown(ak(n,1)) then ;if key is pressed then ;check if it the key has been pressed right now if ak(n,2) = 0 then ;the status was: depressed ;<----------------------------- KEY PRESSED ! endif ak(n,2) = 1 ;set the status to 'pressed' else ;the key is not pressed ;check if the key has been depressed right now if ak(n,2) = 1 then ;<----------------------------- KEY RELEASED ! endif ak(n,2) = 0 ;set the status to depressed endif next
Hope this has sense for you,
Sergio.