function [keyIsDown,secs, keyCode, deltaSecs] = KbCheck(deviceNumber, unusedUntilTime, varargin) % [keyIsDown, secs, keyCode, deltaSecs] = KbCheck([deviceNumber]) % % Return keyboard status (keyIsDown), time (secs) of the status check, and % keyboard scan code (keyCode). % % keyIsDown 1 if any key, including modifiers such as , % or is down. 0 otherwise. % % secs Time of keypress as returned by GetSecs. % % keyCode A 256-element logical array. Each bit % within the logical array represents one keyboard key. % If a key is pressed, its bit is set, otherwise the bit % is clear. To convert a keyCode to a vector of key % numbers use FIND(keyCode). To find a key's keyNumber % use KbName or KbDemo. % % deltaSecs Time in seconds since this KbCheck query and the most % recent previous query (if any). This value is in some % sense a confidence interval, e.g., for reaction time % measurements. If KbCheck returns the information that a % key is pressed by the subject, then the subject could % have pressed the key down anytime between this % invocation of KbCheck at time 'secs' and the most % recent previous invocation. Therefore, 'deltaSecs' % tells you about the interval in which depression of the % key(s) might have happened: [secs - deltaSecs; secs]. % for practical purpose this means that "measured" RT's % can't be more accurate than 'deltaSecs' seconds - the % interval between the two most recent keyboard checks. % Please note however, that standard computer keyboards % can incur additional delays and timing uncertainty of % up to 50 msecs, so the real uncertainty can be higher % than 'deltaSecs' -- 'deltaSecs' is just a lower bound! % % KbCheck and KbWait determine whether any key is down now, including the % meta keys: , , , , and