Time between mouse clicks

Looking for a minimalist stopwatch function that returns the time between two mouse clicks? In other words, I call the function. I click the computer mouse once. I click the computer mouse again. The function returns a real number representing the elapsed time between the mouse clicks.

Have you seen EventHandler[]? And events like "MouseDown" and "KeyDown"? You would also be interested in CurrentValue["EventAbsoluteTime"] or maybe even CurrentValue["EventData"].

Thanks, Michael. I had not seen EventHandler[]. I do not understand all the documentation for it, but I think it only works in a dynamic module. I want a function that returns the interval. I tried the line below without success.

EventHandler[time, {"MouseClicked" :> start = AbsoluteTime\[\];, "MouseClicked" :> time = AbsoluteTime\[\] - start}]

I’m not sure what sort of user interface you have in mind, but this might be like it:

time = DialogInput[
  DynamicModule[{data = Null}, 
   EventHandler[
    Graphics[{{Green, Disk[]}, Inset["Click"]}, 
     ImageSize -> 
      100], {"MouseClicked" :> (If[NumberQ[data], 
        DialogReturn[AbsoluteTime[] - data], 
        data = AbsoluteTime[]])}]]]

You may want to play with the option WindowMargins etc. to figure out how to place the dialog window where you want it.

Or maybe you want some other kind of interface.

Thanks again, Michael. I thought there might be a more direct solution, but DialogInput[] works fine the way you wrote it.