> For the complete documentation index, see [llms.txt](https://docs.polyfrost.org/oneconfig/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.polyfrost.org/oneconfig/config/adding-options/buttons-colors-and-keybinds.md). Agents can also search and read this documentation through its [MCP server](https://docs.polyfrost.org/oneconfig/~gitbook/mcp).

# Buttons, Colors and Keybinds

Learn about the button, color and keybind elements that can be used in a config.

## Buttons

### Common button

The button is a simple interaction that can trigger code when pressed. It's got both single and dual-column variants.

You can create your method to run when the button is pressed using the Runnable interface:

```java
@Button(
    name = "I'm a button",    // name beside the button
    text = "Click me!"        // text on the button itself
)
Runnable runnable = () -> {    // using a lambda to create the runnable interface.
    System.out.println("I was clicked!");
    FMLCommonHandler.instance().exitJava(69, false);
}
```

![Buttons with single and dual variant examples](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2Fp6ThmpXlzxfSHGCQy2Pw%2Fimage.png?alt=media\&token=62b0f1b0-52db-4fd0-928d-942f88b6d76a)

### Keybinds

OneConfig also offers keybinds that replace Minecraft's own keybind system. Basically, it's handled and stored by OneConfig, not the game. It's got both single and dual-column variants.

{% hint style="success" %}
This config component uses OneKeyBind to store the keybinds.
{% endhint %}

```java
@KeyBind(
    name = "I'm a keybind!"
)
// using OneKeyBind to set the default key combo to Shift+S
public static OneKeyBind keyBind = new OneKeyBind(UKeyboard.KEY_LSHIFT, UKeyboard.KEY_S);
```

To register an action when a keybind is activated, add the following to your constructor:

```java
public Config() {
    registerKeyBind(keyBind, () -> System.out.println("Look mom, a keybind!"));
}
```

![Keybind field examples, including recording state](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FhhMy8kGxtwqBpJZUrBmw%2Fimage.png?alt=media\&token=da534bfd-e214-4ca9-be80-6a84e250b3b6)

## Colors

The color option lets the user change any default color to their own, using a built-in color picker.

{% hint style="success" %}
This config component uses [OneColor](https://docs.polyfrost.org/oneconfig/utils/onecolor.md) to store the colors.
{% endhint %}

```java
@Color(
    name = "Background Color"
)
OneColor testColor = new OneColor(26, 35, 143);        // default color
```

![Color examples, single and dual column](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2F2LtHOZWHvEWJ3ZbAsL4Z%2Fimage.png?alt=media\&token=2c7aadc4-037c-4fd1-8c60-a1e6c4a9c7fb)

![Color selector GUI examples](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FTOLE7pfeiKzGIUfclAUH%2Fimage.png?alt=media\&token=b1fd7697-01f2-48fb-895a-9965014f3e7e)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.polyfrost.org/oneconfig/config/adding-options/buttons-colors-and-keybinds.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
