Hello, I am trying to collect keyboard responses with PsychToolbox using KbCheck, but when I run the code the screen freezes and refuses to close. This script is intended to close all screens ONLY after keyboard input 'y' or 'n' (yes/no). I also want to collect which key response was made and the response time. Here is the code I am using to collect responses:
Screen('DrawText', window, 'XXXXX')
[VBL stimulusOnset] = Screen('Flip', window)
acceptedKeys = [KbName('y'), KbName('n')];
responded = 0;
while responded == 0
[tmp,KeyTime,KeyCode] = KbCheck;
if KeyCode(acceptedKeys)
RT = KeyTime - stimulusOnset
strResponse = KeyCode
responded = 1;
end
WaitSecs(0.001);
end
Screen('CloseAll');
Do you have any idea why it is not responding to the correct keyboard inputs? Thank you!