| Reference | Downloads | Github

Show the key response


If this template helps then use it. If not then just delete and start from scratch.

OS: Win10
PsychoPy version: 1.90.1
What are you trying to achieve?:
Participants are shown an artificial word and they have to type in what it means in English. I want the answer they are typing in to show on the screen so that participants can see what they are doing and be able to edit it.

What did you try to make it work?:
I tried some code components, but it isn’t working so I’m not even going to put those in, because I’m definitely doing it wrong.

What specifically went wrong when you tried that?:
I have no error message, but nothing shows up on the screen when I type.


Hi @smile667, take a look at this link below, the code in the code component allows users to type on screen in real time using a text component in Builder.


hi @dvbridges , thank you for that, it does show on the screen now. but now I have no way of tracking what keys were pressed and if the information entered was correct without which is my DV. is it possible to change that?


Ok, you just want the final text that was written from the text component and write the text to the data file. In the code component, in the End Routine tab:

thisExp.addData("textResponse", textComponent.text)  # Where textComponent is the name of your text component


@dvbridges thank you very much, it shows in the data now. Just one more issue on this subject, is there anyway for the entered text to show up as correct or not In the data? I have to give feedback to participants and I cannot do that if there is no “correct response” column in the data (at least I think I can’t).


Sure, it will be a matter of comparing strings between your expected answer and the text component text. If case does not matter, it is a simple bit of code:

# End routine tab

if text.text.lower() == yourAnswer.lower():
    correctResp = 1
    correctResp = 0

In your feedback code, you can write:

if correctResp:
    msg = "Correct"
    msg = "Incorrect"
feedbackText.setText(msg)  # Your feedback text component


@dvbridges thank you so much, everything works now.