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

조회 수: 4 (최근 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