# libtmux:bind-key

- **Package:** libtmux
- **Language:** Common Lisp
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-lisp/blob/c2e5fc4ed3befda21f45dfa5d5868c38fd138311/src/key-bindings.lisp#L67
- **Public owner:** libtmux
- **Page:** https://libtmux.org/en/lisp/latest/reference/libtmux-bind-key/

```
(bind-key client key &key (table "prefix") repeat note (command nil command-p) (command-source nil source-p) cancel-token timeout output-limit)
```

Replace TABLE's KEY binding and return a COMMAND-OUTCOME.
TABLE defaults to prefix. KEY, TABLE and optional NOTE are literal strings.
REPEAT enables native key repetition. Supply exactly one of COMMAND argv or
COMMAND-SOURCE, explicit tmux parser source. COMMAND argv owns each argument
and preserves its token boundary; its first token must not contain =.

Tmux parses the binding immediately. Assignments/directives in COMMAND-SOURCE
can change daemon environment before a later parse error. Aliases expand during
binding in both forms and can also introduce parser side effects. Failure is
not rollback. Ordinary stored command nodes run later on a key event with its
native target context; this does not retain captured-handle authority.

Success acknowledges the binding and its hooks, not later key execution.
Blocks under shared preflight/dispatch limits, acquires no observation and
never retries. Native key/source errors and uncertain outcomes remain inspectable.

See also: `libtmux:error-outcome`, `libtmux:list-keys`, `libtmux:send-keys`, `libtmux:unbind-key`.

## Parameters

- `client`
- `key`
- `table?`
- `repeat?`
- `note?`
- `command?`
- `command-source?`
- `cancel-token?`
- `timeout?`
- `output-limit?`

## tmux command

The tmux commands behind `bind-key`.

- [`bind-key`](/en/tmux/latest/manual/bind-key/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_bind_key_entry`](/en/tmux/latest/reference/c-variable-cmd_bind_key_entry/) (attribute)
- [`cmd_bind_key_exec`](/en/tmux/latest/reference/c-function-cmd-bind-key-c-cmd_bind_key_exec/) (function)

## Guides

Pages that discuss `bind-key`.

- [Explicit operations](/en/lisp/latest/guides/operations/)
