function [times,letters] = trafficTimer
% [times, letters] = trafficTimer 
% --- record the times of events
% type a character key for each event
% ESC to quit
times = []; %! Initialize the state.
letters = [];
%! Additional initialization goes here.
f = figure(1);

while 1 %! Loop: catch events and process them.
    a = waitforbuttonpress; %! Wait for the next event.
    % Process the event.
    time = now; %! Collect the time.
    letter = get(f,'CurrentChar'); %! Collect the key.
    if letter == 27 % ESC character  
        break; %! Exit.
    else %! Update the state.
        times(end+1) = time;
        letters(end+1) = letter;
        %! Additional updating goes here.
    end
end     
%! Post-processing goes here.