How to assign right and left arrow keys to responses

34 views (last 30 days)
Hi,
I am designing an experiment using psychtoolbox which displays words to participants one by one and the task for the participant is to respond to the word using the left arrow key to state if they have seen the word before and the right arrow key to state if they have not seen the word before. How do I do this? This is what I have written so far but when I run it, it just presents all the words really quickly and does not present a word and wait for a left arrow or right arrow response.
for i=1:6,
Screen('TextSize',w, 2*TxtSize); %Scales text to fit in window
DrawFormattedText(w, FlTxt{i}, 'center', 'center', [0,0,0]);
Screen(w, 'Flip'); %Flip to Monitor
while ~keyisDown||~any(strcmp('RightArrow',KbName(KeyCode))||strcmp('LeftArrow',KbName(KeyCode))),
[keyisDown,~,KeyCode]=KbCheck;
end
[timeSecs keyCode] = KbWait;
Screen('PutImage',w,128,ScreenRect); Screen('Flip',w);
if strcmp('ESCAPE',KbName(keyCode)),
Resp=0;
elseif strcmp('RightArrow',KbName(keyCode)),
Resp=1;
elseif strcmp('LeftArrow',KbName(keyCode)),
Resp=-1;
else
Resp=2;
end
  1 Comment
Jack Moore
Jack Moore on 30 Nov 2016
Hey Man,
I'm having a similar problem. trying to make it so that the key press will specify which screen will be presented next... How did you fix your problem?

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!