How to record two simultaneous key responses? (using Psychtoolbox)

조회 수: 19 (최근 30일)
SOJIN YU
SOJIN YU 2018년 11월 27일
댓글: SOJIN YU 2018년 11월 29일
In my experiment design, a pair of participants should press different keys (one should press 'z', the other should press '/' on the same keyboard) to respond to the signal appearing on the same screen. But I want to know how to record two different key responses with very short time intevals.
Hope I can get some advice on how to fix the code below:
while true
[~,~,keyCode]=KbCheck;
if keyCode(KbName('z'))
endtime1=GetSecs
end
end
while true
[~,~,keyCode]=KbCheck;
if keyCode(KbName('/'))
endtime2=GetSecs
end
i=i+1;
break;
end
  댓글 수: 3
SOJIN YU
SOJIN YU 2018년 11월 27일
Thank you for your suggestion! I might not have been too clear explainning my question. The two participants are using the same keyboard, and they know that they are required to press the two corresponding keys at the same time. However, the problem for me right now is that I do not know how to record two key responses given at the same time. Do you have any sugguestions? Thank you in advance!
Walter Roberson
Walter Roberson 2018년 11월 27일
in any experiment in which people are expected to do something at the same time then either person might perform the action first. Your code outline discards all inputs until it sees one particular one and then discards all inputs until it sees the other. If the second person types first your code outline would discard it because it discards everything until it sees the character expected for the first .

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 11월 27일
gotem = false(1,2)
times = zeroes(1,2)
while ~all(gotem)
get a key
[tf,idx] = ismember(the key, appropriate values )
if tf
gotem(idx) = true
times(idx) = GetSecs
end
end
Note that in this code if the same key is pressed multiple times then the last is recorded . Recording the first instead would be easy

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by