> For the complete documentation index, see [llms.txt](https://help.trikset.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.trikset.com/trik/programming-code/object-brick/class-keys.md).

# Класс «keys»

Служит для работы с кнопками на пульте робота.

| Метод                                                                            | Описание                                                                                             |
| -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| [buttonPressed](/trik/programming-code/object-brick/class-keys.md#buttonpressed) | Посылается, когда кнопка с указанным кодом нажата или отпущена.                                      |
| [isPressed](/trik/programming-code/object-brick/class-keys.md#ispressed)         | Возвращает true, если кнопка с указанным кодом нажата в данный момент.                               |
| [reset](/trik/programming-code/object-brick/class-keys.md#reset)                 | Сбрасывает запомненные нажатия кнопок.                                                               |
| [wasPressed](/trik/programming-code/object-brick/class-keys.md#waspressed)       | Возвращает, была ли нажата кнопка с указанным кодом, сбрасывает запомненные нажатия для этой кнопки. |

## buttonPressed

Посылается, когда кнопка с указанным кодом нажата или отпущена.

#### Синтаксис

{% tabs %}
{% tab title="Python" %}

```python
brick.keys().buttonPressed.connect(lambda code, value: brick.stop() if code == KeysEnum.Up else print(code))
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
brick.keys().buttonPressed.connect(function(code, value){if (code==KeysEnum.Up)brick.stop() ; });
```

{% endtab %}
{% endtabs %}

Первый параметр — код кнопки, второй — 1, если кнопка нажата, 0, если отпущена.

## isPressed

Возвращает `true`, если кнопка с указанным кодом нажата в данный момент.\
Возможные варианты:

* `KeysEnum.Left` (код 105),
* `KeysEnum.Up` (код 103),
* `KeysEnum.Down` (код 108),
* `KeysEnum.Enter` (код 28),
* `KeysEnum.Right` (код 106),
* `KeysEnum.Power` (код 116),
* `KeysEnum.Esc` (код 1).

#### Синтаксис

{% tabs %}
{% tab title="Python" %}

```python
brick.keys().isPressed(KeysEnum.Up)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
brick.keys().isPressed(KeysEnum.Up);
```

{% endtab %}
{% endtabs %}

## reset

Сбрасывает запомненные нажатия кнопок.

#### Синтаксис

{% tabs %}
{% tab title="Python" %}

```
brick.keys().reset()
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
brick.keys().reset();
```

{% endtab %}
{% endtabs %}

## wasPressed

Возвращает, была ли нажата кнопка с указанным кодом, сбрасывает запомненные нажатия для этой кнопки.\
Возможные варианты:

* `KeysEnum.Left` (код 105),
* `KeysEnum.Up` (код 103),
* `KeysEnum.Down` (код 108),
* `KeysEnum.Enter` (код 28),
* `KeysEnum.Right` (код 106),
* `KeysEnum.Power` (код 116),
* `KeysEnum.Esc` (код 1).

#### Синтаксис

{% tabs %}
{% tab title="Python" %}

```
brick.keys().wasPressed(KeysEnum.Up)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
brick.keys().wasPressed(KeysEnum.Up);
```

{% endtab %}
{% endtabs %}


---

# 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://help.trikset.com/trik/programming-code/object-brick/class-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.
