Skip to main content

Overview

The mouseDown() method presses the mouse button at an element’s location without releasing it. This is useful for drag operations, custom gestures, or when you need precise control over mouse events. You can either call it on an Element instance or use it directly with a selector.

Syntax

Parameters

When called on an Element, no parameters are required. When called directly on the AI client:

Returns

Returns a Promise<void> that resolves when the mouse button is pressed.

Examples

Basic Drag Operation

Drag and Drop with Direct Selectors

Selecting Multiple Items

Custom Drawing Application

Long Press Gesture

Resizing UI Elements

Important Notes

  • Always pair mouseDown() with mouseUp() to complete the gesture
  • The mouse button remains pressed until mouseUp() is called
  • Use hover() to move the mouse while the button is pressed
  • For simple drag operations, consider using ai() with a natural language description like "drag file to folder"