How to add doubleclick event to Canvas element using the “AddEventListener” method?

I’m just trying to add a double click event to a HTML5 Canvas element. It works fine with:

myCanvas.ondbclick

However, I want to use the addEventListener method to do that. I guess it might be a simple task but I googled everywhere and could not find it. What’s the name of the event I should be using?

myCanvas.addEventListener('doubleclick?', function(){ 

  // Some dazzling stuff happens be here

});

Hope it’s possible, don’t wanted to “break” my coding consistency.

The event name is dblclick:

myCanvas.addEventListener('dblclick', function(){ 

  // Some dazzling stuff happens be here

});

Also your first example is wrong, it should say:

myCanvas.ondblclick


The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .
Read More:   Jasmine - how to spyOn instance methods

Similar Posts