> For the complete documentation index, see [llms.txt](https://daikirai.gitbook.io/scripting/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://daikirai.gitbook.io/scripting/documentation/keybinds.md).

# keybinds

{% hint style="info" %}
minecraft keycodes: <https://minecraft.fandom.com/wiki/Key_codes>
{% endhint %}

### getKeycode

returns the keycode for the specified minecraft keybind name.

```java
int code = keybinds.getKeycode(String key);
```

***

### getMousePosition

returns the current mouse position in pixels as `[x, y]`.

```java
int[] position = keybinds.getMousePosition();
```

***

### isKeyDown

returns `true` if the specified keycode is held.

```java
boolean keyDown = keybinds.isKeyDown(int key);
```

***

### isMouseDown

returns `true` if the specified mouse button is pressed. use `0` for left, `1` for right, and `2` for middle click.

```java
boolean mouseDown = keybinds.isMouseDown(int button);
```

***

### isPressed

returns `true` if the named keybind is currently pressed.

```java
boolean pressed = keybinds.isPressed(String key);
```

***

### leftClick

simulates a left mouse click.

```java
keybinds.leftClick();
```

***

### rightClick

simulates a right mouse click.

```java
keybinds.rightClick();
```

***

### setPressed

sets the pressed state of a keybind as defined in `options.txt`.

```java
keybinds.setPressed(String key, boolean pressed);
```
