> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# MouseEvent

APISummary
Represents a mouse event, inherited from [`Event`](/next/api/lynx-api/event/event.md), which is a type of event that describes the user's interaction with the mouse. For example, mouse click.

:::info
Starting from Lynx 3.8, you can enable W3C Web standard-aligned `MouseEvent` behavior in `pageConfig`.

```js
// pageConfig
import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';

pluginReactLynx({
  alignMouseEventWithW3C: true,
});
```

:::

## Instance property

### button

```ts
button: number;
```

After `alignMouseEventWithW3C` is enabled, when a mouse event is triggered, if any mouse button is pressed or released, an integer value representing this mouse button will be returned.

| Value | Description            |
| ----- | ---------------------- |
| 0     | primary mouse button   |
| 1     | middle mouse button    |
| 2     | secondary mouse button |

### buttons

```ts
buttons: number;
```

After `alignMouseEventWithW3C` is enabled, when a mouse event is triggered, if any buttons are pressed, an integer value representing multiple buttons which user is pressing will be returned. Each button occupies one bit field.

| Bit | Description            |
| --- | ---------------------- |
| 0   | primary mouse button   |
| 1   | secondary mouse button |
| 2   | middle mouse button    |

### x

```ts
x: number;
```

Represents the horizontal axis position of the mouse pointer in the `element` coordinate system that contains the mouse pointer and is closest to the user.

### y

```ts
y: number;
```

Represents the vertical axis position of the mouse pointer in the `element` coordinate system that contains the mouse pointer and is closest to the user.

### pageX

```ts
pageX: number;
```

Indicates the horizontal axis position of the mouse pointer in the current `LynxView` coordinate system.

### pageY

```ts
pageY: number;
```

Represents the vertical axis position of the mouse pointer in the current `LynxView` coordinate system.

### clientX

```ts
clientX: number;
```

Indicates the horizontal axis position of the mouse pointer in the current window coordinate system.

### clientY

```ts
clientY: number;
```

Indicates the vertical axis position of the mouse pointer in the current window coordinate system.

## Type of MouseEvent

### mousedown

Indicates a mouse button is pressed (primary or secondary). [`target`](/next/api/lynx-api/event/event.md#target) is the `element` closest to the user that contains the mouse pointer.

### mousemove

Indicates that the mouse is moving inside the element. [`target`](/next/api/lynx-api/event/event.md#target) is the `element` that contains the mouse pointer and is closest to the user.

### mouseup

Indicates that the mouse button is released on the element. [`target`](/next/api/lynx-api/event/event.md#target) is the `element` that contains the mouse pointer and is closest to the user.

### mouseenter

Indicates that the mouse moves into the activation area of [`target`](/next/api/lynx-api/event/event.md#target) for the first time. [`target`](/next/api/lynx-api/event/event.md#target) is the `element` that contains the mouse pointer and is closest to the user.

Note: the `mouseenter` event does not bubble, and it can't be captured by using [`capture-`](/next/guide/interaction/event-handling/event-propagation.md#event-handler-property) API.

### mouseover

Indicates that the mouse pointer is moved onto the [`target`](/next/api/lynx-api/event/event.md#target) or one of its children. [`target`](/next/api/lynx-api/event/event.md#target) is the `element` that contains the mouse pointer and is closest to the user.

### mouseleave

Indicates that the mouse moves out of the activation area of [`target`](/next/api/lynx-api/event/event.md#target) for the first time. [`target`](/next/api/lynx-api/event/event.md#target) is the same as previous [`mouseenter`](#mouseenter)'s [`target`](/next/api/lynx-api/event/event.md#target).

Note: the `mouseleave` event does not bubble, and it can't be captured by using [`capture-`](/next/guide/interaction/event-handling/event-propagation.md#event-handler-property) API.

## Compatibility

**Compatibility Table**

**Query:** `lynx-api.event.MouseEvent`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/event/MouseEvent.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| MouseEvent | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| button | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| buttons | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| x | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| y | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| pageX | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| pageY | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| clientX | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| clientY | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| mousedown | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| mousemove | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| mouseup | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| mouseenter | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| mouseover | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| mouseleave | No | No | No | Yes (3.7) | Yes (3.7) | Yes |

**`y`**

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/event/MouseEvent.json) · [API Reference](/next/api/lynx-api/event/touch-event)

