psychopy.org | Reference | Downloads | Github

Use of numeric pad (numbed)

Hello,

I am designing an experiment and I want participants to answer 92 maths questions. I would like to record their answers. However, when I allow them to use key pad (using ‘num_1’, ‘num_2’ etc.), their answers look like

(for instance) num_2num_5 (for 25).

How can I avoid from this?

Thanks!

Hi @em_zey_maths, you cannot actually avoid this for the numpad, because that is the name assigned to the keycodes of the numpad (at least on Mac and Linux). What you could do is create a new data column with your answer at the end of each routine, with the ‘num_’ string removed.

thisExp.addData("correctedAnswer", resp.replace('num_', '')

The resp variable is your actual response as a string, so you will need to change this accordingly.

1 Like

Thank you for your prompt reply. I am happy with your answer. I could easily do that.

However, during the experiment, when participants type their answers, they get the same thing. If they use the num pad and type 23, they see num_2num_3 on the screen as their answer. It might be strange for them to see such a response. Is there any way to avoid this? I do not think what you describe solves this, am I right?

Thank you so much for your reply.

Sure, that means you are setting the text onscreen according to the key press? If so, then call the replace method on the string as you set the text.

thanks David. I could not figure out what ‘replace method’ means? I am really very novice user :frowning: But many many thanks for your reply. Could you direct me to any recourses on this?

I am also attaching my file if anybody wants to help (only if they have time)!

Latest Experiment.psyexp (39.9 KB)
Part 0.xlsx (11.6 KB)

Sure, so in Trial routine you have a code component that you using to detect key presses. When there is a keypress, you are setting the onscreen text of your Feedback_1 text component with the label of the key that was pressed. So, just add the above replace method to the string you are creating from the keypresses:

screen_text1 = ''.join(key_Resp_1.keys).replace('num_', '')

Thank you so much. It worked :slight_smile: I really appreciate your help.

Many thanks and best wishes.