clc;
clear all;
close all;
rng('shuffle');

% useful command, waits here until all keys on the keyboard are released
KbReleaseWait;

% start a clock using the tic and doc commands these are very useful
tic;
% play a beep
Beeper(600,0.6 ,0.05);
% start an infinite loop
while 1
      
      % read the current status of the keyboard
      [x y buttons] = GetMouse;
      % this returns some key information
      % keyIsDown is a variable that is a 1 if a key is pressed and 0 if no key is pressed
      % secs is the time of the key press
      % keyCode is a vector for each key, a 1 will appear in the vector for the key that has been pressed

     % this is a logic test, if any of the mouse buttons are pressed
     if sum(buttons) > 1
         % uses toc to get the time difference from tic
         reaction_time = toc;
         break;
     end

end
disp(['Your reaction time was ' num2str(reaction_time) ' seconds']); 