参考 doubleClicked()

doubleClicked()

当鼠标按钮快速双击时调用一次的函数。

声明函数 doubleClicked() 会设置一个代码块,当用户快速按下并释放鼠标按钮两次时自动运行:

function doubleClicked() { // Code to run. }

鼠标系统变量,如 mouseXmouseY,在调用 doubleClicked() 时会更新为它们最新的值:

function doubleClicked() { if (mouseX &lt; 50) { // Code to run if the mouse is on the left. } <p> if (mouseY &gt; 50) { // Code to run if the mouse is near the bottom. } } </p>

参数 event 是可选的。doubleClicked() 总是传递一个 MouseEvent 对象,该对象带有描述双击事件的属性:

function doubleClicked(event) { // Code to run that uses the event. console.log(event); }

在触摸屏设备上,放置在 doubleClicked() 中的代码将在短时间内发生两次触摸后运行。

浏览器可能会将默认行为附加到各种鼠标事件上。例如,一些浏览器在用户按下鼠标按钮同时移动鼠标时会高亮显示文本。为了防止此事件的任何默认行为,在函数的末尾添加 return false;

示例

语法

doubleClicked([event])

参数

event

optional MouseEvent argument.

Notice any errors or typos? Please let us know. Please feel free to edit src/events/mouse.js and open a pull request!

相关参考