# Input

{% hint style="info" %}
Remember: In order to register input methods, [`screen.listen()`](/quick-reference/screen.md#input) must be called after your methods in your program!
{% endhint %}

## All Input Methods

* `mousedown` | When the mouse is pressed or is held, this will be called
* `mouseup`     | When the mouse is released this is called
* `mousedrag` | When the mouse is dragged, this is called anytime the mouse moves and is held.
* `mousemove` | When the mouse moves, this method is called.
* `keydown`     | When a key is pressed or is currently being held, this is called
* `keyup`         | When a key is released this is called
* `exit`           | Called when the Screen is abruptly closed or [`screen.exit()`](/quick-reference/screen.md) is called.

## Example

```python
from pydraw import *

screen = Screen(800, 600, 'Input Example')

box = Rectangle(screen, 375, 275, 50, 50, Color('gray17'))

# another cool thing to know is the 'button' parameter is optional!
def mousedown(location, button):
    box.color(Color.random())


def mouseup(location, button):
    box.rotate(1)


def mousedrag(location, button):
    box.border(Color.random())


def mousemove(location):
    box.lookat(location)


def keydown(key):
    if key == 'w':
        box.move(dy=-5)
    elif key == 's':
        box.move(dy=5)
    if key == 'a':
        box.move(dx=-5)
    elif key == 'd':
        box.move(dx=5)


def keyup(key):
    if key == 'v':
        box.clone()


screen.listen()

fps = 30
running = True
while running:
    screen.update()
    screen.sleep(1 / fps)
```


---

# 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.pydraw.graphics/quick-reference/input.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.
