I am using PTB in Matlab 2011b to record reaction time data in an experiment via KbCheck. I, of course, am interested in reducing the response input latency as much as possible. I've read several other messages on this forum about typical HID keyboards/mice not being suitable for this application with latencies around 8-10ms, and other devices were recommended such as mechanical gaming keyboards, response boxes, etc. Using HIDIntervalTest, I've tested several different keyboards:
1) Typical HP membrane keyboard
2) Cherry MX 6.0 Mechanical USB Keyboard with Cherry MX Red Switches
3) Empirisoft DirectIN modified Apple keyboard
The results from HIDIntervalTest for each of the three keyboards are attached. From these results, it does look like the HP keyboard does indeed have a delay between samples of around 8-10ms. Is it correct to conclude that both the Cherry and Empirisoft keyboards are sampling at rates of <1ms? Is 1ms the final latency of the response, or are there other sources of latency in the overall system? Are there any other tests (besides KeyboardLatencyTest since I don't have access to a microphone with an audio jack connection) that could identify which of the two keyboards would be preferential to use for my experiment? Are there any settings or anything else that I'm not thinking of that could improve the overall performance of the keyboard for response time measurement?
I've included the relevant sections of my code below in case some improvements could be made there, as well:
for i=1:length(StimulusOrder)
%display stimulus
Screen('DrawTexture',windowPtr,image);
vbl=Screen('Flip',windowPtr, vbl+(round(ISI/ifi)-.5)*ifi );
%send stimulus event code
IOPort('Write',handle,uint8([109 104 eventCode 0]));
WaitSecs(0.01);
IOPort('Write',handle,uint8([109 104 0 0]));
StimulusTime(i)=vbl;
%check for key presses during display of stimulus
keyTime=0;
while keyTime-StimulusTime(i)<(SPT)
[keyIsDown,keyTime,keyCode]=KbCheck;
if keyIsDown==1 %only take the first button press and then stop looking for button presses
IOPort('Write',handle,uint8([109 104 Event_PartResp 0]));
WaitSecs(0.01);
IOPort('Write',handle,uint8([109 104 0 0]));
ResponseTime(i)=keyTime;
break
end
end
%display fixation cross
Screen('DrawTexture',windowPtr,FixationCrossTexture); %draw fixation cross texture on window
vbl=Screen('Flip',windowPtr, vbl+(round(SPT/ifi)-.5)*ifi);
%send fixation cross event code
IOPort('Write',handle,uint8([109 104 Event_FixCross 0]));
WaitSecs(0.01);
IOPort('Write',handle,uint8([109 104 0 0]));
EventOrder_Actual(end+1,1)=Photocell_FixCross;
%check for key presses during display of fixation cross if a button
%wasn't already pressed during display of stimulus
if keyIsDown==0
while keyTime-StimulusTime(i)<(SPT+ISI)
[keyIsDown,keyTime,keyCode]=KbCheck;
if keyIsDown==1 %only take the first button press and then stop looking for button presses
IOPort('Write',handle,uint8([109 104 Event_PartResp 0]));
WaitSecs(0.01);
IOPort('Write',handle,uint8([109 104 0 0]));
ResponseTime(i)=keyTime;
break
end
end
end
%record any responses made during (SPT+ISI)
ParticipantResp{i,1}=keyCode; % "C"=67, "M"=77
clearvars keyIsDown keyTime keyCode;
end
Thanks!