How to present a stimulus on the screen depending on the user keyboard response
4 views (last 30 days)
Show older comments
I am using Psychtoolbox on MATLAB R2020a, on Windows 10. I am trying to present a certain stimulus depending on the user’s keyboard response. I have used if-else statements to achieve this but only the fixation cross is displayed. I also do not know how to differentiate between the keyboard response given to begin the trial and that which will be used to determine the next stimulus.
For instance, I want the user to press an arrow key. Then, the user presses any button to begin the next stage. The next stimulus presented depends on the response provided after the question mark. Thanks!
% Check the keyboard to see if a button has been pressed
[keyIsDown,secs, keyCode] = KbCheck;
% Present stimulus
if keyCode(leftKey)
Screen('DrawText', window, num2str(seq1), rightX, rightY, [0 1 0]);
Screen('DrawText', window, num2str(seq3), leftX, leftY, [1 0 1]);
Screen('Flip', window);
WaitSecs(0.5);
elseif KbCheck == rightKey
Screen('DrawText', window, num2str(seq2), leftX, leftY, [1 1 0]);
Screen('DrawText', window, num2str(seq3), rightX, rightY, [1 0 1]);
Screen('Flip', window);
WaitSecs(0.5);
elseif KbCheck == upKey
Screen('DrawText', window, num2str(seq1), rightX, rightY, [0 1 0]);
Screen('DrawText', window, num2str(seq2), leftX, leftY, [1 1 0]);
Screen('Flip', window);
WaitSecs(0.5);
end
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!