Counting keystrokes in Opensesame
Hi! I'm developing an experiment on Opensesame for the first time. I have to show a series of visual stimuli (three images, 60 sec per image) and count how many times the subject presses the spacebar while watching the image for 60 sec. (A text explaining why pressing the button must be shown before). How can I do that and count separately for each image?
I already tried with the graphic interface but I did't reach my goal and unfortunately i can't code with phyton, can someone help me? 😊
Comments
Hi Silvia,
it is never to late to learn Python. When you experience that you need to implement something that you can't yet, chances are high that you will need to do so again. So it might be worth the investment. See for example here for Python resources: https://pythontutorials.eu/
As for your problem, implementing it in Python is the easiest option I think, but you can also get around it, if you do following:
infinite.In Python you just need one inline_script:
images = ['a.png', 'b.png', 'c.png'] cv = Canvas() kb = Keyboard() timeout = 60000 for image in images: counter = 0 cv.image(path = exp.pool[image] start_time = cv.show() while clock_time() - start_time < timeout: k, t = kb.get_key() if k is not None: counter += 1 log.write_vars()Good luck,
Eduard
Thank you so much for your help! I've tried the graphic interface approach but something didn't work, so I tried to copy your python script but it returns a syntax error in line 9, can you help me to fix it, please?
Please share your experiment. Screenshots are not as useful to identify the problems.
Eduard