I would like to ask the user to respond to a question with a key press and then click the button below to move to the next question. In my code the key response is registering whether its left or right mouse. it would be of great help if someone could point out what is wrong?
> [keyIsDown1, RTkeyCode1] = KbCheck;
> if IsInRect(x1,y1,rect58)
> Screen('FrameRect', window , [1 0 0], rect58,5)
> if any(buttons1)
Your question is unclear to me, but you need to run your code depending on if the user actually pressed the button, so you need to:
noResponse = true; %determine when to leave while loop, could also use break directly
[keyDown, keyCode] = KbCheck(-1);
% the rest of your logic should be here
if any(buttons); noResponse = false; end
WaitSecs('YieldSecs', 0.01); %throttle the loop a bit
Or use KbWait that saves you having to run the outer loop…
Thanks for the response. I didn’t mean that. Let me rephrase myself, I’m presenting a question which asks them to rate something and the user gives their answer by giving a key response, in this case they rate it by a number. after giving the response, the user need to click on a rect on the same screen,right below the question to move to the next question.