# unbindKey (Shared)

> Removes binds this resource made on a key.

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

## Syntax

```lua
bool unbindKey(player thePlayer, string key [, string keyState = both, function|string handler = nil])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `thePlayer` | `player` | Server only: the player the bind belongs to. On the client, leave this argument out. |
| `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 remove: `"down"`, `"up"` or `"both"`. *(default: `both`)* |
| `handler` | `function\|string` | The function or command name to unbind. Without it, every function this resource bound to the key is unbound, but not the commands. *(default: `nil`)* |

## Returns

`true` if a bind was removed, `false` if there was none.

## Example

```lua
local function openMenu()
    showCursor(true)
end

bindKey("m", "down", openMenu)

addCommandHandler("nomenu", function()
    unbindKey("m", "down", openMenu)
end)
```

## See also

- [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.
- [isKeyBound (Shared)](https://wiki.mymp.gg/en/isKeyBound.md): Tells whether this resource bound a function to a key.
- [getFunctionsBoundToKey (Shared)](https://wiki.mymp.gg/en/getFunctionsBoundToKey.md): Lists the functions this resource bound to a key.
