# libtmux.Server.bind_key

- **Module:** libtmux.Server
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/9fdd083a8181a827889337b63cd4e6daea661a8c/src/libtmux/server.py#L664
- **Page:** https://libtmux.org/en/py/latest/reference/libtmux-server-bind_key/

```
libtmux.Server.bind_key(self, key: str, command: str, key_table: str | None = None, note: str | None = None, repeat: bool | None = None) -> None
```

Bind a key to a command via ``$ tmux bind-key``.

## Parameters

- `self`
- `key` (str): Key to bind (e.g. ``C-a``, ``F12``, ``M-x``).
- `command` (str): Tmux command to run when key is pressed.
- `key_table` (str | None): Key table to bind in (``-T`` flag). Defaults to ``prefix``.
- `note` (str | None): Note for the binding (``-N`` flag).
- `repeat` (bool | None): Allow the key to repeat (``-r`` flag).

## Example

```python
>>> server.bind_key('F12', 'display-message test', key_table='root')
>>> server.unbind_key('F12', key_table='root')
```
