Skip to content

Instantly share code, notes, and snippets.

Last active May 12, 2023 12:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
doubleClickHandler - handles double-click events on elements
* Handles the click event to detect single or double clicks.
* @param {MouseEvent} event - The click event object.
function doubleClickHandler(event) {
const target =;
if (new Date().getTime() - (target._lastTouch || 0) > 500) {
// Not a double click
target._lastTouch = new Date().getTime();
} else {
// A double click
// Default event will proceed, do additional stuff here
// Attach the click event listener to the element with the ID 'doubleclick'
document.getElementById('doubleclick').addEventListener('click', doubleClickHandler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment