# libtmux.Server.bind_key

- **Module:** libtmux.Server
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/server.py#L664
- **Page:** https://libtmux.org/reference/py/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')
```
