How to present a stimulus on the screen depending on the user keyboard response

2 次查看(过去 30 天)
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 个)

类别

Help CenterFile Exchange 中查找有关 Timing and presenting 2D and 3D stimuli 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by