How can I record all keyboard responses without ending the routine?

I would like for each trial to finish only after a correct response has been made, but I would like for all keys pressed, during each routine, to be recorded and stored in the data spreadsheet. Is this possible to accomplish in builder mode?

-Drew

Hi Drew,

It’s certainly possible in buildier.

Set your keyboard up thus:

And in a code component have the following code on each frame:

if len(key_resp_2.keys) > 0:
    if key_resp_2.keys[len(key_resp_2.keys)-1] == corAns:
        continueRoutine = False

Where corAns is the column with the correct answer in your conditions file.

You’ll now have a list of keys pressed stored in your key_resp_2.keys column in excel.

Best wishes,

Oli

Very insightful! I actually figured out a way to do it using a list, but I think I like your way better. I did run into another snag though. During the practice round, I set up the keyboard component to record the last response and, at the end of the block, assess the participants accuracy to determine whether or not they can proceed. Obviously, this counter is now ineffective, being that only correct responses are accepted. How can I set up the keyboard component to assess only the first response?

Thanks again,

-Drew

Hi Drew,

To access the first of multiple responses you would just use the list index e.g key_resp_2.keys[0] however if you just want one key to be recorded you could use the code from the extended stroop demo which gives participants accuracy and rt feedback.
Bw
Oli

Yeah, I was trying to do something like that, but I am very inexperienced and new to coding. This is what I tried doing:

Not quite sure what you are trying to achieve with your above code… Do you want the practice trials to end after participants have made 8 correct first responses?

If I take your meaning from the other threads - what you want to happen is:

Record all keystrokes
End routine when the correct key is pressed
Give feedback based on the first key pressed

The first two steps are detailed above - for the last one you would have:

#start of experiment
number_cor = 0

#end of routine
if key_resp_2.keys[0] == corAns:
   msg = 'Correct' #feedback message - see the extended stroop demo
   number_cor +=1
   if number_cor == 8:
     trials_5.finished = True

elif key_resp_2.keys[0] != corAns:
   msg = 'incorrect'

Wonderful! That was exactly what I was looking for. Thank you for your help.

-Drew

Also, I already have a feedback message. It’s displayed in the routine following the trial task.
It looks like this:

Beginning of experiment

msg=""

Beginning of routine

msg=“Your reaction time=%.3f” %(key_resp_9.rt)

This worked well prior to the most recent changes.

Per your suggestion, I tried:

if key_resp_9.keys[0] == corrAnswer:
msg=“Your reaction time=%.3f” %(key_resp_9.rt)

When I do this, I get, “Type error: float argument required, not list.”

I kind of understand what this means, but I don’t know a way around it.

because you’re saving so many keys, the RT will be saved as a list. If you just want the first RT do key_resp_9.rt[0]

That makes sense. Thank you!

-Drew

Hi,

How can we save and store key responses when doing a digit span task in which the correct answer is a set of digits for one stimulus. for example, the column for the correct answer in CSV contains some digits as in the following:
corrAns
[‘4’,‘9’, ‘7’, ‘2’]
[‘3’, ‘7’, ‘4’, ‘5’]
[‘5’, ‘9’, ‘6’, ‘0’]

Hello,

I was wondering if the last response time of the list is the response time to digit all the sequence or just the last number. Do you know?

Regards,
Larissa