Help with keyDown!

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
notHalfBad
Posts: 4
Joined: Thu May 26, 2016 12:47 am

Help with keyDown!

Post by notHalfBad » Wed Jun 01, 2016 3:04 am

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!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Help with keyDown!

Post by dunbarx » Wed Jun 01, 2016 4:58 am

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

notHalfBad
Posts: 4
Joined: Thu May 26, 2016 12:47 am

Re: Help with keyDown!

Post by notHalfBad » Wed Jun 01, 2016 7:35 am

Thanks! this solved my problem. You're a legend!

Post Reply