Record the total time spacebar was held down for and record in excel data file

Hi all
I’m new to pyschopy and running an experiment on time perception. Pps have to estimate time duration of a stimulus by pressing and holding the space bar, releasing the space bar once the estimated time duration ends. The code that Im currently using works, however its produces two or more recorded value in ‘hold times’. I need only one value to appear. can someone ?