2

I wonder if there is any way to calculate mouse click in seconds.

Just to make it clear, if user keeps the mousedown for 5 seconds, I wanna write to console '5 sec' etc.

There is any way to do it?

Thanks!

2

2 Answers 2

2

Get a startDate on mouseDown then get endDate on mouseUp and calculate difference between these dates, convert second. And.... just console.log :)

2

Well, I think you should have a look at the Date object in Javascript, as well as to the events being fired during a click (mousedown is not the only one).

2
  • I really want to write a thorough answer to this question, but you really wrote a great answer here. +1.
    – AJFarkas
    Commented Feb 24, 2015 at 21:35
  • Well thanks, there are a few tricky aspects to consider, but that's to the OP to find out and come back if he still needs help.
    – Loufylouf
    Commented Feb 24, 2015 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.