psychopy.org | Reference | Downloads | Github

How to present the response from the keyboard component

Hi there,

Sorry, i’m new to this.

I have a loop running and I’m using the keyboard component to get a response. There are two options on the screen and you can press ‘a’ or ‘k’ to make a selection. As soon as a selection is made, I would like to display the key the user pressed but bolded. I tried using $key_resp.keys but that resulted in only square brackets being displayed [].

How would I go about doing this?

Thanks!

Hello Aalim Makani

insert a feedback-routine following your response-routine in which the participants press ‘a’ or ‘k’. In the feedback-routine add a code-component. Insert
keyPressed = event.getKeys()
in the Begin Routine tab of this component. Add a text-component to the feedback-routine following the just mentioned code-component. Add as text to the text-component something like
$'You pressed: ' + str(keyPressed)
Set the text to set every repeat

Best wishes Jens

Hi Jens,

Thank you so much for your help with this. It works.

Much appreciated.

Aalim