A minor question:Control slider without mouse

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

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v2022.2.4
Standard Standalone? (y/n) If not then what?:y
What are you trying to achieve?:
I could control the slider markposition with the following code:
but when I want to confirm the rating number,I fail by using the keyboard like “space” untill I click it.
How to use “space” to get the rating response instead of clicking?
Many thanks for your help!

Can you just add the following?

elif 'space' in keys:
        continueRoutine = False 

Hi @wakecarter
Thank you so much for your reply!
I have tried to add the code below,the ‘Space’ got response,but the data couldn’t record it.Just like the following photo.

Looking forward to your reply again!
Many thanks in advance!

Try putting


in End Routine

Thanks again for your prompt reply!
I have tried to add the code like yours,just name ‘Rating’
However,I couldn’t get ‘slider.rt’ unless I click it with mouse.
Is there any way to get RT by pressing my ‘space’?
Thank you very much!

The variable t is the time from the start of the routine. You could save it to the data file in End Routine or (slightly more accurately) within the Each Frame code where you are ending the routine.

Hi @wakecarter
I am extremely grateful for your help!
Yes,It works! :100:
According to your advice,I add the variable t in End Routine and Each Frame.

  • Each Frame:
    elif 'space' in keys:
        continueRoutine = False 
        thisExp.addData("RT_Each Frame", t)
  • End Routine
thisExp.addData("RT_End Routine", t)

I highly recommend adding the codes below when your experiment sets a limited time to response.

  • If your participant response in time:
    RT_Each Frame = RT_End Routine (almost)

  • If your participant fail to response in time:
    RT_Each Frame:Duration of the Routine(maybe useful)
    RT_End Routine:None

Again,thank you very much for your help! @wakecarter
Best wishes,