MouseDown

This event occurs when a user presses a button on a mouse device.

Syntax

Private Sub object_MouseDown(button, shift, x, y)

Parameters

object
Object expression that evaluates to a control or Form object.
button
Integer that identifies the chosen button, either the left or the right button.
shift
Returns an integer that corresponds to the state of the SHIFT, CTRL, and ALT keys when a user presses or releases the left or right button, as specified in the button parameter.
x, y
Returns a number that specifies the current location of the pointer of the mouse device.

Remarks

Use a event procedure to specify actions that occur when a user presses or releases a button of a mouse device. Unlike the Click and DblClick events, MouseDown events enable you to distinguish between the left and right buttons on a mouse device.

The following table shows the constants you can use to test for the button parameter.

Constant
Value
Description
vbLeftButton 1 Left button is pressed.
VbRightButton 2 Right button is pressed.
VbMiddleButton 4 Unsupported.

The following table shows the constants you can use to test for the shift parameter.

Constant
Value
Description
vbShiftMask 1 SHIFT key is pressed.
VbCtrlMask 2 CTRL key is pressed.
VbAltMask 4 ALT key is pressed.

You can use a MouseMove event procedure to respond to an event caused by moving the mouse device. The button parameter for MouseDown differs from the button parameter used for MouseMove. For MouseDown, the button parameter indicates exactly one button per event, whereas for MouseMove, the button parameter indicates the current state of all buttons.