# server.keys.KeyBinding

- **Module:** server.keys
- **Package:** libtmux
- **Language:** Rust
- **Kind:** struct
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/server/keys.rs#L60
- **Page:** https://libtmux.org/en/rs/latest/reference/server-keys-keybinding/

One key binding, as tmux holds it.

`bind-key -n` is `-T root`, so [`Self::table`] answers it. The command is
the text a `bind-key` line in a configuration file carries, with `\;`
between commands, and is not parsed further. That is argument syntax: as
the single command string [`Server::bind_key`] takes, `\;` is a literal
semicolon rather than a separator.

## Example

```rust
let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();
server.bind_key("prefix", "Y", "display-message hello").await?;

let version = server.capabilities().await?.tmux_version().clone();
if version.has_behavior(&libtmux::since::LIST_KEYS_FORMAT) {
    let bindings = server.typed_key_bindings(Some("prefix")).await?;
    let bound = bindings
        .iter()
        .find(|binding| binding.key() == "Y")
        .ok_or("the binding is listed")?;
    assert_eq!(bound.command(), "display-message hello");
    assert!(!bound.repeats());
    assert_eq!(bound.note(), None);
}

guard.shutdown().await?;
```

## Members

- `table` (method): Return the key table, such as `prefix`, `root` or `copy-mode-vi`.
- `key` (method): Return the key as tmux names it, such as `C-b` or `"`, unquoted.
- `command` (method): Return the bound command list, as a `bind-key` line renders it.
- `note` (method): Return the note `bind-key -N` attached, if any.
- `repeats` (method): Report whether the binding repeats, `bind-key -r`.
