

For each time the participant presses a key, I would like to log the time at which this happens and the duration of the keypress. Than 20 seconds of nothing, and then once again the emotion could reappear for another 40 seconds.

one could feel an emotion beginning after 10 seconds, feel this emotion for 5 seconds. What I would like to achieve is for the whole stimulus to be played, during which both the onset time and the duration of each key press is logged.

Once the key is released, the sequence proceeds to the next item, although the sound is still playing in the background. Secondly, this allows me to record only one keypress. However, this raises two problems: first of all, the "key_down_time" value is very high, possible counting from the beginning of the experiment and not from the onset of the audio stimulus (of which I set the duration at 0 so it would begin to collect keyboard responses right away). I tried the inline script found in this post:, by adding these two lines to get the exact times: I would like to log both the time at which the participants starts pressing the key as well as the duration of the keypress. I am trying to set up a listening experiment in which I ask the participant, while listening to an audio stimulus, to press a key when they feel a certain emotion and to keep it pressed for as long as they feel this emotion.
