# Keys

Provides functions for working with key names and codes.

***

## Accessing the Module

```lua
local KEYS <const> = exports.boii_utils:get("modules.keys")
```

***

## Shared

### get\_keys()

Returns the full key list as a table.

#### Parameters

*None*

#### Returns

* `table`: A mapping of key names to key codes.

#### Example

```lua
local all_keys = KEYS.get_keys()
print(all_keys["e"]) -- 46
```

***

### get\_key(key\_name)

Gets the key code for a given key name.

#### Parameters

| Name      | Type     | Description                |
| --------- | -------- | -------------------------- |
| key\_name | `string` | Name of the key (e.g. "e") |

#### Returns

* `number|nil`: Key code if found, or `nil` if not.

#### Example

```lua
local code = KEYS.get_key("f")
if code then
    print("Key code for F is:", code)
end
```

***

### get\_key\_name(key\_code)

Gets the key name for a given key code.

#### Parameters

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| key\_code | `number` | The code to look up |

#### Returns

* `string|nil`: The key name if found, or `nil` if not.

#### Example

```lua
local name = KEYS.get_key_name(244)
if name then
    print("Key 244 is:", name)
end
```

***

### print\_key\_list()

Prints the full list of key names and codes to the console.

#### Parameters

*None*

#### Returns

*None*

#### Example

```lua
KEYS.print_key_list()
```

***

### key\_exists(key\_name)

Checks if a given key name exists in the key table.

#### Parameters

| Name      | Type     | Description       |
| --------- | -------- | ----------------- |
| key\_name | `string` | Key name to check |

#### Returns

* `boolean`: `true` if the key exists, `false` otherwise.

#### Example

```lua
if KEYS.key_exists("enter") then
    print("Enter key exists")
end
```


---

# Agent Instructions: 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:

```
GET https://docs.boii.dev/old-docs/boii_utils/api/keys.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
