+ 1

How do I know if a player double clicks?

I am making an Html game using JavaScript and Im wondering how to register when the player has double clicked

6th Dec 2019, 9:33 AM
Lemonades For Sale
Lemonades For Sale - avatar
2 Respuestas
+ 4
There is a event "dblclick" which triggers when the user double click on an element Like inline <button ondblclick="alert('Hi')">Click here</button> Or using addEventListener Element_var.addEventListerner("dblclick", function(){ //Code })
6th Dec 2019, 10:19 AM
Farhan
Farhan - avatar
+ 3
If there is no builtin way to do so, you should make a boolean variable, that's gets true when mouse button is clicked, then it has a certain time delay when it changes back to false. When mouse button gets clicked when the boolean variable is true, it's assumed as double click. And the wanted action can be launched.
6th Dec 2019, 9:43 AM
Seb TheS
Seb TheS - avatar