# Mouse

### Events

There are individual events for the up and down events for left, right, and middle mouse buttons: `onLeftDown`, `onLeftUp`, `onRightDown`, `onRightUp`, `onMiddleDown`, `onMiddleUp`.

```typescript
Mouse.onLeftDown.Connect(() => {
    print("Left button down");
});

Mouse.onLeftUp.Connect(() => {
    print("Left button up");
});
```

### Polling

The state of each button can also be checked with the `IsLeftButtonDown` (et. al.) methods.

```typescript
if (Mouse.IsLeftButtonDown()) {
    print("Left button down");
}

if (Mouse.IsRightButtonDown()) {
    print("Right button down");
}

if (Mouse.IsMiddleButtonDown()) {
    print("Middle button down");
}
```

## Movement

### Events

The `Moved` event fires when the mouse is moved. The `onScrolled` event fires when the scroll wheel is moved.

```typescript
Mouse.onMoved.Connect((screenPosition) => {
    print("Mouse position", screenPosition);
});

Mouse.onScrolled.Connect((delta) => {
    print("Scrolled", delta);
});
```

### Polling

Use the `position` field and `GetDelta` method to retrieve information about mouse movement.

```typescript
// Get current position of mouse:
const screenPosition = Mouse.position;

// Get movement of mouse since last frame:
const delta = Mouse.GetDelta();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.airship.gg/unity-for-airship/user-input/mouse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
