# getCommandsBoundToKey (Client)

> Lists the commands bound to a key on this client.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Keyboard
- **URL**: https://wiki.mymp.gg/en/getCommandsBoundToKey

## Syntax

```lua
table getCommandsBoundToKey(string key [, string keyState = both])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `key` | `string` | The key's name, in any case: `a` to `z`, `0` to `9`, `F1` to `F12`, `mouse1` to `mouse5`, `mouse_wheel_up`, `mouse_wheel_down`, `arrow_l`, `num_0`, `space`, `enter`, `lshift` and others. |
| `keyState` | `string` | Which binds to look at: `"down"`, `"up"` or `"both"`. *(default: `both`)* |

## Returns

A table mapping each command name to the argument string it was bound with. It is empty if there are none.

It counts the command binds of every client resource.

## Example

```lua
for command, arguments in pairs(getCommandsBoundToKey("F2", "down")) do
    outputDebugString(command .. " " .. arguments)
end
```

## See also

- [getBoundKeys (Client)](https://wiki.mymp.gg/en/getBoundKeys.md): Lists the keys bound to a command on this client.
- [getKeyBoundToCommand (Client)](https://wiki.mymp.gg/en/getKeyBoundToCommand.md): Tells which key runs a command on this client.
- [bindKey (Shared)](https://wiki.mymp.gg/en/bindKey.md): Binds a key to a function or a command. The function runs when the key is pressed, released or both.
