The mouseEvent module provides mouse events reported by a device. It is inherited from InputEvent.
import { MouseAction, Button, Axis, AxisValue, MouseToolType, MouseEvent } from '@kit.InputKit'; Enumerates mouse event types.
System capability: SystemCapability.MultimodalInput.Input.Core
| Name | Value | Description |
|---|---|---|
| CANCEL | 0 | Canceled. The down event of the mouse is interrupted unexpectedly and does not close normally. For example, the CANCEL event is triggered when the mouse button is pressed but not released, the window transitions to the background, or an abnormal destruction occurs. |
| MOVE | 1 | Moving of the mouse pointer. |
| BUTTON_DOWN | 2 | Mouse button press. |
| BUTTON_UP | 3 | Mouse button release. |
| AXIS_BEGIN | 4 | Beginning of the mouse axis event. |
| AXIS_UPDATE | 5 | Updating of the mouse axis event. |
| AXIS_END | 6 | Mouse axis event ended. |
| ACTION_DOWN11+ | 7 | Touchpad press. |
| ACTION_UP11+ | 8 | Touchpad release. |
Enumerates mouse buttons.
System capability: SystemCapability.MultimodalInput.Input.Core
| Name | Value | Description |
|---|---|---|
| LEFT | 0 | Left button. |
| MIDDLE | 1 | Middle button. |
| RIGHT | 2 | Right button |
| SIDE | 3 | Side button. |
| EXTRA | 4 | Extended button. |
| FORWARD | 5 | Forward button. |
| BACK | 6 | Back button. |
| TASK | 7 | Task button. |
Enumerates mouse axis types.
System capability: SystemCapability.MultimodalInput.Input.Core
| Name | Value | Description |
|---|---|---|
| SCROLL_VERTICAL | 0 | Vertical scroll axis of the mouse. |
| SCROLL_HORIZONTAL | 1 | Horizontal scroll axis of the mouse. |
| PINCH | 2 | Pinch axis of the mouse. |
Defines the mouse axis type and axis value.
System capability: SystemCapability.MultimodalInput.Input.Core
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| axis | Axis | No | No | Enumerates mouse axis types. |
| value | number | No | No | Mouse axis value. |
Enumerates tool types.
System capability: SystemCapability.MultimodalInput.Input.Core
| Name | Value | Description |
|---|---|---|
| UNKNOWN | 0 | Unknown type. |
| MOUSE | 1 | Mouse. |
| JOYSTICK | 2 | Joystick. |
| TOUCHPAD | 3 | Touchpad. |
Defines the mouse event.
System capability: SystemCapability.MultimodalInput.Input.Core
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| action | Action | No | No | Enumerates mouse event types. |
| screenX | number | No | No | X coordinate of the mouse event in the relative coordinate system with the upper-left corner of the specified screen as the origin. Currently, only integers are supported. The unit is pixels. |
| screenY | number | No | No | Y coordinate of the mouse event in the relative coordinate system with the upper-left corner of the specified screen as the origin. Currently, only integers are supported. The unit is pixels. |
| windowX | number | No | No | X coordinate in the relative coordinate system with the upper-left corner of the window where the mouse is located as the origin. Currently, only integers are supported. The unit is pixels. |
| windowY | number | No | No | Y coordinate in the relative coordinate system with the upper-left corner of the window where the mouse is located as the origin. Currently, only integers are supported. The unit is pixels. |
| rawDeltaX | number | No | No | X coordinate offset of the current mouse event relative to the last event. Currently, only integers are supported. The unit is pixels. |
| rawDeltaY | number | No | No | Y coordinate offset of the current mouse event relative to the last event. Currently, only integers are supported. The unit is pixels. |
| button | Button | No | No | Enumerates mouse buttons. |
| pressedButtons | Button[] | No | No | Button being pressed. |
| axes | AxisValue[] | No | No | Defines the mouse axis type and axis value. |
| pressedKeys | KeyCode[] | No | No | List of pressed keys. |
| ctrlKey | boolean | No | No | Whether ctrlKey is being pressed. The value true indicates that the key is pressed, and the value false indicates the opposite. |
| altKey | boolean | No | No | Whether altKey is being pressed. The value true indicates that the key is pressed, and the value false indicates the opposite. |
| shiftKey | boolean | No | No | Whether shiftKey is being pressed. The value true indicates that the key is pressed, and the value false indicates the opposite. |
| logoKey | boolean | No | No | Whether logoKey is being pressed. The value true indicates that the key is pressed, and the value false indicates the opposite. |
| fnKey | boolean | No | No | Whether fnKey is being pressed. The value true indicates that the key is pressed, and the value false indicates the opposite. |
| capsLock | boolean | No | No | Whether capsLock is enabled. The value true indicates that capsLock is enabled, and the value false indicates the opposite. |
| numLock | boolean | No | No | Whether numLock is enabled. The value true indicates that numLock is enabled, and the value false indicates the opposite. |
| scrollLock | boolean | No | No | Whether scrollLock is enabled. The value true indicates that scrollLock is enabled, and the value false indicates the opposite. |
| toolType11+ | ToolType | No | No | Tool type. |
| globalX20+ | number | No | Yes | X coordinate of the mouse event in the global coordinate system with the upper-left corner of the primary screen as the origin, in px. When being used as an output parameter, its value is reported by the system. |
| globalY20+ | number | No | Yes | Y coordinate of the mouse event in the global coordinate system with the upper-left corner of the primary screen as the origin, in px. When being used as an output parameter, its value is reported by the system. |