function TestGUI
FigH = figure('WindowButtonDownFcn', @myClick, ... % Mouse click
'WindowKeyPressFcn', @myClick); % Key press
handles.running = false;
handles.time = 0;
guidata(FigH, handles);
end
function myClick(hObject, EventData)
handles = guidata(hObject);
if handles.running % Display the time between clicks:
disp(etime(clock, handles.time));
handles.running = false;
else % Start the timer:
handles.running = true;
handles.time = clock;
end
guidata(hObject, handles);
end