Page 1 of 1

Help with keyDown!

Posted: Wed Jun 01, 2016 3:04 am
by notHalfBad
Hi there, I'm making a game.
I have a problem in that I want to make sure that the program I'm making keeps track of the keys that are pressed and makes sure that the effect that occurs per key pressed only happens once.

So if I pressed the letter a once, then I could press a all I liked after that, but none of the scripts written for that key would run, until I restarted the game.
I am at a loss for how to do this.

Whoever can solve this for me gets a cookie!

Re: Help with keyDown!

Posted: Wed Jun 01, 2016 4:58 am
by dunbarx
Hi.

Not sure of the structure of your game. but try this on a new card with one field on it. In the card script:

Code: Select all

on keyDown tKey
   if tKey is not in fld 1 then
     --doSomethingWithEachNewKeyPress
     put tKey after fld 1
   end if
end keyDown
Here a field "keeps track" of the keys already pressed. Perhaps this will give you a clue how to proceed?

Craig Newman

Re: Help with keyDown!

Posted: Wed Jun 01, 2016 7:35 am
by notHalfBad
Thanks! this solved my problem. You're a legend!