Page 1 of 1
Wait for keyDown response
Posted: Mon Dec 19, 2016 9:26 pm
by starfirescully
I am trying to create a reaction time experiment.
Right now I have a button that begins the experiment, coded to display a fixation cross, picture, and word.
I have codes that control what each keyDown response does on the card.
After the button displays the word, I would like it to wait to continue until a keyDown response has been recorded. Is there a way to do this?
Thanks!
Re: Wait for keyDown response
Posted: Mon Dec 19, 2016 10:11 pm
by dunbarx
Hi.
Not sure I see the problem. Yet.
1- You show several objects, as you say. Finished, done.
2- Then you want the user to press a key that does something. Certain keys are handled, I assume in a keyDown (or up) handler in the card script. Or wherever.
So the system is already "waiting" if you see what I mean. That is, the keydown message is a separate event, independent of anything that went before. There is no process "wait" required in this case; I see no connection between the two.
Or do I have this wrong?
Craig Newman
Re: Wait for keyDown response
Posted: Mon Dec 19, 2016 10:27 pm
by starfirescully
Craig,
That makes sense! I managed to fix the issue. This originally didn't work because I had the "waiting" within a repeat loop, so it didn't actually wait.
Thanks!
Re: Wait for keyDown response
Posted: Mon Dec 19, 2016 10:31 pm
by starfirescully
Now I just have to figure out how to make sure only the specific keys work, and no others.
Thanks!
Re: Wait for keyDown response
Posted: Mon Dec 19, 2016 10:44 pm
by dunbarx
Good going.
The "keyDown" message takes a single parameter. You would do something like:
Code: Select all
on keyDown tKey
if tKey = thisKey then doSomething
if tKey = thatKey then doSomethingElse
end keyDown
This will only process the keys you are interested in. But be careful, you will have trapped a very important message. If this is in the card script, for example, you will not be able to type into a field. Can you make the above handler more robust on your own? If so, fine. If not, look up the "pass" control structure before asking here.
Craig