KbEventGet() not working

Hi all,

I would like to monitor keyboard input of the 4 letters s,x,k and m with KbEventGet(). The code is similar to this:

deviceIndex = []; 
keysOfInterest = zeros(1, 256);
keysOfInterest(KbName('s')) = 1;
keysOfInterest(KbName('x')) = 1;
keysOfInterest(KbName('k')) = 1;
keysOfInterest(KbName('m')) = 1;

KbQueueCreate(deviceIndex, keysOfInterest);
KbQueueStart(deviceIndex);

KbEventFlush(deviceIndex);
   
% wait for a keypress
key_pressed = false;
while ~key_pressed
    key_ev = KbEventGet(deviceIndex);
    if (~isempty(key_ev) && key_ev.Pressed)
        key_pressed = true;
    end
    
    % wait for 1 msec to prevent system overload
    WaitSecs('Yieldsecs', 0.001);                
end

So in my understanding, the code above should leave the while-loop as soon as one of the four keys is pressed. This does however not work. I remain stuck within the while-loop no matter how often I press one of the keys, as KbEventGet() does not seem to notice any keyboard input.

What am I doing wrong?

I am using PTB 3.0.16 - Flavor: beta - Corresponds to SVN Revision 10582 with MATLAB R2019a on Manjaro Linux, Kernel 4.14.209-1-MANJARO.

Your code looks right to me, and it works for me as you expect (on Windows). Does KbQueueDemo work for you? Can you update to the latest PTB (3.0.16 is unsupported)?

I updated PsychToolbox and now it works fine. Thanks!