waitfor or Demo
Jaap MurreIllustrates how to use the waitfor ... or statement to wait for several events at once. As soon as one occurs, processing of the script continues. It also illustrates how to style a button.
If you are a registered user and signed in, you can here copy this script and its stimuli to your own account, where you can edit it and change it in any way you want.
It is absolutely free to register (no credit card info asked!). You can then instantly copy this experiment with one click and edit it, change its accompanying texts, its landing page, stimuli, etc. Invite your colleagues, friends, or students to check out your experiment. There is no limit on how many people can do your experiment, even with a free account.
The catch? There is no catch! Just keep in mind that with a free account, you cannot collect data. For teaching that is usually not a problem. For research, prepaid data collection (unlimited subjects) starts as low as €10.00 for a 10-day period.
var e, n, response, left = addblock(10,80,15,10).button("Yes"), right = addblock(75,80,15,10).button("No"); var esc = addblock(80,5,15,10).button("Quit","navigation","quit","quit_button") .style("background-color","bisque","#quit_button"); while (true) { n = randint(1,11); text(n + " is larger than 5"); waitfor { e = left.await('click'); response = "yes"; } or { e = right.await('click'); response = "no"; } or { awaitkey('ESCAPE'); break; } or { esc.await('click'); break; } or { await(3000); text("Please, answer within 3 seconds"); await(1500); } text("You clicked " + response); await(1000); clear(); } text("Thanks!"); await(1000);