I want to detect the pressing of a Y or N key ( after a request for consent )
I put the keybord component for this
and I try to make a code so that if N
then it displays a thank you message on the screen for 10 seconds and quits the experiment ends the experiment without saving
my problem is the display and the timing.
a print does not display on the screen
You haven’t said what you’ve tried but assuming you tried to add a message to a quit command in code, I don’t think that works. You could show the message in a normal text component on a routine and then quit at the end of the routine.
I assume you are checking for n not N
even via a code?
currently I have 4 components in the same routine
- a consent text
- a keyboard “key_resp” with allowed keys ‘y’, ‘n’ and the forced end routine box checked
- then a code in the end routine tab
keys = event.getKeys()
if ‘n’ in keys:
Set up the window
msg = ‘you choose to not continue’
print(msg)
core.wait(5)
continueRoutine = False
#core.quit()
- text component with message $msg
but it doesn’t work. it can’t work since the routine ends before. because of (2)
and if I place this component (4) in a following routine with text $msg. I have a blank screen. as if the variable msg remained null
I tried with the print() command but I want to have a display on the screen and not on the console
but via a code. because if I use the text component it does not work
print is used in Python and PsychoPy to print to the console. It translates to console.log in JavaScript.
If you have a mistake in your text component or associated code then I would recommend trying to fix that rather than switching to a method that definitely won’t work.