---
title: "input"
---

> Documentation Index
> Fetch the complete documentation index at: https://aesthetic-docs.pages.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# input

Raw key/mouse state from the window, plus cursor grabbing.

Movement/action keybinds and overrides live in [`options`](/options).

| Function | What it does |
|----------|--------------|
| `input.key_down(code)` | `true` while a key is held (GLFW code, e.g. `32` = space) |
| `input.mouse_down(btn)` | `true` while a mouse button is held (`0` left, `1` right, `2` middle) |
| `input.mouse_pos()` | Cursor `x, y` in `render_2d` canvas pixels |
| `input.mouse_locked()` | `true` while the cursor is grabbed |
| `input.lock()` | Grabs the cursor (hides and locks it) |
| `input.unlock()` | Releases the cursor |

```lua
if input.key_down(340) then  -- left shift
local x, y = input.mouse_pos()
print(x, y)
end
```

Source: https://aesthetic-docs.pages.dev/input/index.md
