[avail, numChars] =
CharAvail
CharAvail returns the availability of characters in the keyboard event
queue and sometimes the queue's current size. "avail" will be 1 if characters are
available, 0 otherwise. "numChars" may hold the current number of
characters in the event queue, but in some system configurations it is
just empty, so do not rely on numChars providing meaningful results,
unless you've tested it on your specific setup.
Note that this routine does not actually remove characters from the event
queue. Call
GetChar to remove characters from the queue.
CharAvail works on all platforms with Matlab and Java enabled. It works
also on M$-Windows under matlab -nojvm mode. It does not work on OS-X or
Linux in Matlab -nojvm mode and it also doesn't work under GNU/Octave.
GetChar and
CharAvail are character-oriented (and slow), whereas
KbCheck
and
KbWait are keypress-oriented (and fast). See
KbCheck.
See also:
GetChar,
ListenChar,
FlushEvents,
KbCheck,
KbWait,
KbDemo,
Screen Preference Backgrounding.
Psychtoolbox/PsychBasic/CharAvail.m