report keypress only once at a time during real time loop

Hey!

I have a programmin problem and after a full-time-week of trial +
lots of errors I'm asking for help. I'm working on a Win operated PC.

I'd like to run a for-loop with a drifting grating. During that
keypresses and the secs will be saved. My problem is now that it
always returns one keypress several times because the loop is still
running during the keypress. If I use 'while KbCheck; end' it
returns the keypress only once but it pauses during that, which is
not good. I also played around with CharAvail,touch etc.

I use this loop:

for i=1:1:n;
SCREEN(window,'WaitBlanking');
SCREEN('CopyWindow', wa(1+mod(i,frames1)),window,r,rr);
[keyIsDown,secs,keyCo de] = KbCheck;
responsesecs = secs;
if keyIsDown
char = KbName( keyCode);
if keyCode(right)
fprintf(fid,'right,%.3f \n',responsesecs-startSecs);
end
if keyCode(left)
fprintf(fid,'left,%.3f \n',responsesecs-startSecs);
end
end
end



I'd also like to run the loop with Rush, but there I have problems
with the timing.Any ideas on that?

Additionally I'd like to know if it is possible to combine two
grating to a plaid (maybe by making a look-though-the-backgroud-
grating), and if so, how?!

Thanks sooo much for any suggestions.


Best wishes,

Timo