Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] Monitoring keypresses throughout an experiment

edited January 2012 in OpenSesame

I just wanted to follow up from my bug report ( I understand why you made the tradeoff in the design decision. However, is there some way to receive keyboard input during this time between trials? Essentially, the task I'm designing allows the participant to press a particular key at any time throughout the experiment so that, when a particular point in the next trial has been reached, this key can be acted upon. I feel like it should be possible with PyGame's event queue, though this doesn't seem to be accessible from inline scripts. Is there any way to detect if a particular keyboard key has been pressed within the last trial? It doesn't need to use the keyboard_response paradigm, though I've been using this as a hacky way of implementing what I have now.



  • edited October 2011

    Hi Max,

    Welcome to the forum!

    You can indeed use the PyGame event queue. Actually, the openexp.keyboard classes are just very thin wrappers. Around PyGame in the case of the legacy and opengl back-ends, around PsychoPy in the case of the psycho back-end.

    The reason why it doesn't work is that the keyboard is flushed before the start of each sequence (at the start of the run phase, more specifically). The idea behind this was that it allows the user to press escape to abort the experiment and to prevent carry-over effects from one trial to the next. But it's good that you bring it up, so I can make this behavior optional for the next release. I'll let you know when I committed a patch.

    But for now, no, there's no way you can do that. But I seem to remember that you run Linux, right? In that case you can just hack the source code. You can comment out "libopensesame/" on line 42 in the run() method, and the flushing is gone. This file could be in "/usr/share/pyshared/libopensesame/" or "/usr/lib/pymodules/Python[version]/libopensesame/", depending on your method of installation.

    [Edit: I just found that there's also a flush in libopensesame/, line 145]



    Hope this helps!

    Regards, Sebastiaan

  • edited 7:02PM

    Possible as of 0.25. Marking as solved.

Sign In or Register to comment.