KbWait Not Working

PTB version: 3.0.17 - Flavor: beta - Corresponds to SVN Revision 11387
I am using late 2018 MacBook Air, macOS Big Sur 11.1 and Matlab R2020b.

My problem is that KbWait does not wait or return anything.
I want KbWait to wait for 5 seconds, so I passed 5 for the third argument (i.e., KbWait(-1, [], 5);).
It appears that KbWait is immediately skipped for some reason.
I have checked the security setting on my Mac and Matlab has the permission for input monitoring. KbDemo worked fine, so I am not sure why this is not working.

Could someone please explain what I am missing?
Thank you.

ListenChar(2) % suppress key inputs in Matlab command line
while(1)
    Screen('Flip', win);
    disp('RIGHT BEFORE KBWAIT');
    [secs, keyCode, deltaSecs] = KbWait(-1, [], 5);
    % if there is key press, break out of this loop
    if keyCode
        disp('keypress detected');
        break;
    end
    disp('KBWAIT SKIPPED')
end

After running, command line just says:

‘’’
RIGHT BEFORE KBWAIT
KBWAIT SKIPPED
‘’’

You don’t specify wait time in seconds, but until when it should wait:

KbWait(-1, [], 5); ==> KbWait(-1, [], GetSecs + 5);

This was free advice. We appreciate if labs contribute back financially. See PsychPaidSupportAndServices for info how you can contribute.
-mario