p5.js doubleClicked() Function Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The doubleClicked() function is invoked whenever a mouse or pointing device causes a dblclick event. This happens when the pointing device is clicked twice in quick succession on a single element. The MouseEvent callback argument could be used to access the details of the click. Syntax: doubleClicked([event]) Parameters: This function accepts a single parameter as mentioned above and described below: event: This is an optional MouseEvent callback argument. It can be used to access the click details. The program below illustrate the doubleClicked() function in p5.js: Example 1: Using double click to change the fill color. javascript let colorVal = 0; function setup() { createCanvas(500, 300); textSize(24); } function draw() { clear(); // apply fill based on the red component fill(colorVal, 128, 255 - colorVal) text("Double click to change the color", 20, 20); circle(150, 150, 200); } function doubleClicked() { // change the value if // the event occurs if (colorVal < 255) colorVal += 50; else colorVal = 0; } Output: Example 2: Accessing the details of the MouseEvent object. javascript let y = 60; function setup() { createCanvas(500, 200); textSize(16); text("Double click the mouse to see doubleClicked() function fire", 10, 20); } function doubleClicked(event) { // get the x and y location // of the double click locationX = event.x; locationY = event.y; locString = "Mouse was double clicked at location: " + locationX + ", " + locationY; text(locString, 10, y); y = y + 20; console.log(event); } Output: Online editor: https://editor.p5js.org/ Environment Setup: https://www.geeksforgeeks.org/javascript/p5-js-soundfile-object-installation-and-methods/ Reference: https://p5js.org/reference/#/p5/doubleClicked Comment More info S sayantanm19 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-p5.js Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings6 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in Javascript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)9 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readJavascript Scope3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like