Or any other key...

10 views (last 30 days)
Brett
Brett on 30 Nov 2012
This is my code:
[keyIsDown,secs,keyCode, deltaSecs] = KbCheck
while keyIsDown == 0; %Will present this screen until a key is pressed
[keyIsDown, secs, keyCode, deltaSecs] = KbCheck;
%RT = GetSecs - starttrial - time;
if q1tri == 1 && q1col == 1 && keyCode(1,98) == 1 %down
Screen('FillRect',window,[0 0 0])
Screen('Flip',window)
WaitSecs(tar);
elseif q1tri == 2 && q1col == 1 && keyCode(1,104) == 1 %up
Screen('FillRect',window,[0 0 0])
Screen('Flip',window)
WaitSecs(tar);
elseif q1tri == 3 && q1col == 1 && keyCode(1,100) == 1; %left
Screen('FillRect',window,[0 0 0])
Screen('Flip',window)
WaitSecs(tar);
elseif q1tri == 4 && q1col == 1 && keyCode(1,102) == 1; %right
Screen('FillRect',window,[0 0 0])
Screen('Flip',window)
WaitSecs(tar);
end
What this says is that when a target color is present, and the keyboard arrow key matches the arrow displayed it produces a black screen for a particular amount of time. What I need is code that says something like if any other key is pressed (including the arrow keys that don't match), it produces a black screen for a different amount of time. I tried using pause and input commands, but they didn't seem to work. :(
any help, would be super appreciated, Brett
  2 Comments
Jan
Jan on 30 Nov 2012
I do not understand the question. I do neither know the function KbCheck(), not the values of the variables q1col, q1tri and tar. What is "the arraow displayed"? Is the replied keyCode really a vector?

Sign in to comment.

Answers (1)

Jan
Jan on 30 Nov 2012
Edited: Jan on 30 Nov 2012
I try to guess:
Screen('FillRect',window,[0 0 0])
Screen('Flip',window)
keyIndex = find(keyCode(1, [98, 104, 100, 102])); % ???
if q1col && length(keyIndex) == 1 && (q1tri == keyIndex)
WaitSecs(tar);
else
WaitSecs(theOtherTar);
end

Community Treasure Hunt

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

Start Hunting!