simultaneous keyboard and voice response check

I am wondering if anyone has come up with a good routine for simultaneously
checking for a keyboard and voice response? Using KbCheck/CharAvail and
recordsound, I came up with the routine below which sits in the main while loop
until the subject has hit a key and spoken into the microphone. It seems to
work okay. Voice responses are sensed more reliably with a longer recordsound
period, but a longer record sound period reduces the precision of both response
time stamps. (i.e., keysecs and voicesecs) I am using what I believe is a
standard Apple microphone (pictured at the top of
http://www.jayceland.com/AppleParts/) plugged into the microphone jack.

Just looking for some feedback and any suggestions. Thanks.

- Dan


-----------------------------------------

clear all;
disp('Start of program.');

startpause = GetSecs;
while (GetSecs - startpause < 0.5) end

keyIsDowncheck = 1;
ycheck = 1;
while (keyIsDowncheck | ycheck)
[keyIsDown,secs,keyCode] = KbCheck;
if ((keyIsDown | CharAvail) & keyIsDowncheck)
keyIsDowncheck = 0
keysecs = secs;
end
[y,Fs] = recordsound(0.05);
if (max(y) > 0.05 & ycheck)
ycheck = 0
voicesecs = GetSecs;
end
end

disp('End of program.');
fprintf('%4.3f\t%4.3f\n',keysecs - startpause - 0.5,voicesecs - startpause - 0.5);