keyboard need help

I'm using kbcheck to get keyboard input. But it seems thant I can't
get all of them, some of my inputs were stolen by matlb. How to
prevent this?

thanks,
jihong
What do you mean "stolen by matlab"? One of the first things that comes to
mind is that if you hold a key down, it wont read any other key being
pressed. This can be worked around by putting an empty while statement in.
For example:
[keyIsDown time keyCode]=kbCheck;
if keyIsDown
while kbcheck; end; %wait until key is released
...
end

Past that, it depends on what kind of input that you are trying to get
from the keyboard.
Hope this helps!
Mike Pesavento

On Wed, 26 Mar 2003, jihong1974 wrote:

>
> I'm using kbcheck to get keyboard input. But it seems thant I can't
> get all of them, some of my inputs were stolen by matlb. How to
> prevent this?
>
> thanks,
> jihong
>
>
>
> Yahoo! Groups Sponsor
>
> ADVERTISEMENT
> width
> width
> http://psychtoolbox.org
> POST a message to: psychtoolbox@yahoogroups.com
> UNSUBSCRIBE by sending a blank message to:
> psychtoolbox-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
Jihong,

As an alternative code 1 or code 2, try this version. This is how I
count specific keypresses within a time period and, as shown, I
believe it accomplishes the same objectives as your code:

count = 0;
start_time = GetSecs;
while (GetSecs - start_time < 20)
WaitSecs(0.1);
while (GetSecs - start_time < 20)
[keyIsDown,secs,keyCode] = KbCheck;
if (keyIsDown)
if (keyCode(KbName('down')))
count = count + 1
break;
end
end
end
while (GetSecs - start_time < 20)
[keyIsDown,secs,keyCode] = KbCheck;
if (~keyCode(KbName('down')))
break;
end
end
end

- Dan


--- In psychtoolbox@yahoogroups.com, "jihong1974"
<jihong1974@y...> wrote:
> After read these replies carefully, I revised my code and It
comes
> out that the problem is due to my program.
> if I use the code 1, there will be some key loss. if I use code 2,
it
> works fine.
>
> code 1:
>
> count=0;
> start_time=getsecs;
> while getsecs-start_time < 20
> waitsecs(0.1);
> [keyIsDown,timeSecs,keyCode] = KbCheck;
> if keyCode(kbName('down'))
> count=count+1
> end
> while kbcheck; end;
> end
>
> code 2 :
> count=0;
> start_time=getsecs;
> while getsecs-start_time < 20
> waitsecs(0.1);
> [keyIsDown,timeSecs,keyCode] = KbCheck;
> if keyIsDown
> while kbcheck; end;
> if keyCode(kbName('down'))
> count=count+1
> end
> end
> end
>
> Although I till don't know why, anyway my programm works
now.
>
> thanks very much for your guys kind responds,
>
> jihong
> --- In psychtoolbox@yahoogroups.com, "Allen W. Ingling"
> <Allen.Ingling@n...> wrote:
> >
> > On Wednesday, March 26, 2003, at 01:15 PM, jihong1974
wrote:
> >
> > >
> > > I'm using kbcheck to get keyboard input. But it seems thant
I
> can't
> > > get all of them, some of my inputs were stolen by matlb.
How to
> > > prevent this?
> > >
> > > thanks,
> > > jihong
> > >
> > >
> >
> > Some time ago we had the problem with the Win
Psychtoolbox that
> > CharAvail would report a char but a subsequent call to
GetChar
> would
> > not return a character. We had theory that Matlab was
stealing
> > characters from the event queue. In fact the cause was
something
> > other, we were masking for the wrong events, and I fixed it
quite a
> > while ago.
> >
> > I am not aware of a similar problem with Win KbCheck. Can
you
> supply a
> > script which demonstrates the problem ? It is important to
> document
> > the problem soon, even if I can't take time out now to fix it.
> >
> > --Allen