kbcheck question

Hello,

Is there anyway to check for keypresses that might be occurring
simultaneously? If for example, the 'a' key is pressed and an RT is
recorded, but then the 'b' key is pressed while the 'a' key is still
down --can I get the 'b' key as it occurs? I'm looking to trigger a
function the moment the 'b' key is pressed, whether or not any other key
is still down.

Hope this is clear.

Thanks in advance,
Karl Doron
Boston University
Karl,

The keyCode array returned by kbcheck holds the status of all keys at any time.
So, just continue checking the status of the keys using kbcheck, while registering whether
particular keys have been pressed.

so do something like:
akey=kbname('a');
bkey=kbname('b');
tEnd=10;
akeypressed=0;
bkeypressed=0;
stop=0;
tStart=getsecs;

while stop==0
[keyIsDown,secs,keyCode] = KbCheck

if keyCode(akey)
akeypressed=1;
rt=getsecs-tStart;
end

if keyCode(akey)
bkeypressed=1;
end

if akeypressed==1 & bkeypressed==1
stop=dosomethinguseful; % set stop to 0 if useful thing has been done
end

if getsecs-tstart>tend
break;
end
end



--- In psychtoolbox@yahoogroups.com, Karl Doron <karld@b...> wrote:
>
> Hello,
>
> Is there anyway to check for keypresses that might be occurring
> simultaneously? If for example, the 'a' key is pressed and an RT is
> recorded, but then the 'b' key is pressed while the 'a' key is still
> down --can I get the 'b' key as it occurs? I'm looking to trigger a
> function the moment the 'b' key is pressed, whether or not any other key
> is still down.
>
> Hope this is clear.
>
> Thanks in advance,
> Karl Doron
> Boston University