> For the complete documentation index, see [llms.txt](https://docs.quickclient.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.quickclient.cc/actions/keys.md).

# Клавиши и бинды

Состояние клавиатуры и мыши, коды клавиш и способы назначить действие на клавишу.

`keys()` показывает, что на самом деле зажато на клавиатуре и мыши. Он опрашивает систему напрямую, поэтому даёт верный результат даже при открытом экране и не зависит от биндов Quick.

```java
@Override
public void onTick() {
    if (keys().inputBlocked()) return;
    if (keys().isDown(Keys.LEFT_SHIFT) && keys().mouseDown(Keys.MOUSE_RIGHT)) chat("Зажаты Shift и ПКМ");
}
```

## Keys

| Метод                            | Тип       | Описание                                                 |
| -------------------------------- | --------- | -------------------------------------------------------- |
| `isDown(key)`                    | `boolean` | зажата ли клавиша, код GLFW                              |
| `mouseDown(button)`              | `boolean` | зажата ли кнопка мыши: 0 левая, 1 правая, 2 средняя      |
| `mouseX()`, `mouseY()`           | `float`   | положение курсора в пикселях окна                        |
| `cursorLocked()`                 | `boolean` | захвачен ли курсор камерой                               |
| `lockCursor()`, `unlockCursor()` | `void`    | захватить или отпустить курсор                           |
| `inputBlocked()`                 | `boolean` | занят ли ввод чатом, меню Quick или текстовым полем      |
| `name(key)`                      | `String`  | подпись клавиши, как её показывает Quick: `"Left Shift"` |
| `code(name)`                     | `int`     | код по подписи или `Keys.UNKNOWN`                        |

Положение курсора возвращается в пикселях, а `Render2D` рисует в единицах интерфейса. Для перевода делите координаты на `control().guiScale()`.

## Коды

Готовые константы: `Keys.LEFT_SHIFT`, `LEFT_CONTROL`, `LEFT_ALT`, `SPACE`, `ENTER`, `TAB`, `ESCAPE`, `MOUSE_LEFT`, `MOUSE_RIGHT`, `MOUSE_MIDDLE`, `UNKNOWN`. Остальные клавиши задаются обычными кодами GLFW: коды букв совпадают с ASCII заглавных букв (`'F'` = 70), коды цифр с ASCII цифр.

## Три способа назначить действие на клавишу

| Способ                       | Когда использовать                                                                |
| ---------------------------- | --------------------------------------------------------------------------------- |
| `hotkey("Имя", 'F', action)` | игрок должен сам переназначать клавишу в меню; Quick вызовет действие при нажатии |
| `on(KeyEvent.class, …)`      | нужны модификаторы, отпускание клавиши или реакция при открытом экране            |
| `keys().isDown(…)` в тике    | важно само удержание клавиши, а не момент нажатия                                 |

Подробнее про хоткей в [Видах настроек](/settings/types.md), про события на странице [Подписка на события](/events/basics.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.quickclient.cc/actions/keys.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
