+ 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
2 Réponses
+ 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
})
+ 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.