> For the complete documentation index, see [llms.txt](https://learnpython.strivemath.com/p5-python-web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learnpython.strivemath.com/p5-python-web/reference/built-in-variables/mouse.md).

# Mouse

## `mouseX`

It tells the **x-coordinate** of the mouse relative to the **default origin** (either `TOP_LEFT` or `BOTTOM_LEFT`) in the **current** frame.

![](https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2F5TKmV64bSn8VKEpbpW5w%2FmouseX.gif?alt=media\&token=c3606b45-b39e-4138-b967-4c1851dd5b7b)

## `mouseY`

It tells the **y-coordinate** of the mouse relative to the **default origin** (either `TOP_LEFT` or `BOTTOM_LEFT`) in the **current** frame.

![](https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FPQjLqHL3rCdipZ8AlIFl%2FmouseY.gif?alt=media\&token=fc1e5cf7-b3ec-4700-b667-b270f9192805)

## `pmouseX`

It tells the **x-coordinate** of the mouse relative to the **default origin** (either `TOP_LEFT` or `BOTTOM_LEFT`) in the **previous** frame.

## `pmouseY`

It tells the **y-coordinate** of the mouse relative to the **default origin** (either `TOP_LEFT` or `BOTTOM_LEFT`) in the **previous** frame.

## `mouseMovedX`

It tells us how much did the **mouse move horizontally** since the last frame. It's then equivalent to the value `mouseX - pmouseX`

## `mouseMovedY`

It tells us how much did the **mouse move vertically** since the last frame. It's then equivalent to the value `mouseY - pmouseY`

## `winMouseX`

This built-in variable contains the current horizontal position of the mouse, relative to origin of the window.

## `winMouseY`

This built-in variable contains the current vertical position of the mouse, relative to origin of the window.

## `pwinMouseX`

This built-in variable contains the horizontal position of the mouse in the previous frame, relative to origin of the window.

## `pwinMouseY`

This built-in variable contains the vertical position of the mouse in the previous frame, relative to origin of the window.

## `mouseButton`

It stores the **label** of the last mouse button that was pressed. It returns one of three values `"left"`, `"right"`, `"center"`.\
When the sketch is run and nothing is pressed yet, it takes the value `0`.

You can use these **built-in constants** instead

```python
LEFT = "left"
RIGHT = "right"
CENTER = "center"
```

## `mouseIsPressed`

It returns the value `True` if **any** mouse button is **currently** pressed. It returns `False` otherwise.

{% hint style="info" %}
Find these documents helpful? Let the people who made them help your child learn to code at [**Strivemath**](https://www.strivemath.com/)<mark style="color:blue;">**!**</mark>

We'd love to hear your Feedback/Comments [here](https://docs.google.com/forms/d/e/1FAIpQLSeqorBAGTya-YBRI-VFjJxtgQtCz3ucGDI96K96sNyuaGuvdw/viewform?usp=sf_link).
{% endhint %}
