| Reference | Downloads | Github

Maintain key pressed

Hello everybody :smiley:

My participants are supposed to keep a key pressed while they see different pictures pass. One picture represents one trial. The pictures are replaced without any break (so it looks like a movie).
I would like to record for each picture if the key was pressed or not.

I’m new in the coding world and hope to find someone here who could tell me a way of coding this type of response :slight_smile:

Thank you very much in advance for any help :smiley:

You should use the new Psychtoolbox Keyboard class, rather the old event module, which you’ll probably find a lot of code examples for online but is being deprecated. An advantage of the Keyboard class is that it allows you to measure the duration of a keypress, which it sounds like you need:

But the first task will be to lay out your trial logic very carefully before trying to code it up, because this sort of task can get complicated, if, for example, a keypress could start during one picture and not be released until the following one, and so on.