# LibTmux\Send-TmuxKey

- **Package:** LibTmux
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.PowerShell/SendTmuxKeyCommand.cs#L7
- **Page:** https://libtmux.org/en/powershell/latest/reference/libtmux-send-tmuxkey/

```
Send-TmuxKey
    [-Pane] <LibTmux.Pane>
    [-Key] <System.String[]>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
```

Send an ordered sequence of tmux key tokens to a native pane.

Each array element is interpreted by tmux as a key token, such as <kbd>C-a</kbd>
or <kbd>[`Enter`](/en/csharp/latest/reference/libtmux-sendkeysrequest-enter/)</kbd>. Unrecognized key names follow tmux's character-sending
behavior. No additional <kbd>[`Enter`](/en/csharp/latest/reference/libtmux-sendkeysrequest-enter/)</kbd> is appended. Null, empty and
NUL-containing tokens are rejected before I/O. The command owns a snapshot
of the supplied array.

[`Keys`](/en/csharp/latest/reference/libtmux-server-keys/) run in input order through one core command chain. A failure can leave
earlier keys delivered and prevent later keys from running.

The endpoint and daemon generation come from the supplied native pane.
[`-WhatIf`](/en/powershell/latest/reference/libtmux-send-tmuxkey/#LibTmux%5CSend-TmuxKey.parameter.WhatIf) performs no acquisition or sending. Confirmation names the endpoint
and pane without displaying the supplied text or keys. Successful sending
confirms tmux accepted input; use an explicit application readiness signal
before checking that a command has finished.

### Notes

Failures use [`Tmux.KeySendFailed`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.PowerShell/SendTmuxKeyCommand.cs)
and retain the original core exception, its dispatch information and the failed pane.
[`-ErrorAction Continue`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.4#-erroraction)
permits later owners to be processed;
[`-ErrorAction Stop`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.4#-erroraction)
stops on the first failure. NUL and invalid key-token content use
[`Tmux.InvalidInput`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.PowerShell/SendTmuxKeyCommand.cs) before dispatch;
PowerShell handles parameter binding errors. Cancellation stops pending work
but cannot undo delivered input. Nothing is retried.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/reference/glossary/#cmdlet)
- **Confirmation:** Supports `-WhatIf` and `-Confirm`; confirm impact: Medium.
- **Positional binding:** Enabled.
- **Pipeline inputs:** `LibTmux.Pane`: A native pane selected from an explicit endpoint.
- **Outputs:** `System.Void`

Related APIs:

- [Choose endpoints and owners](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/read.md)
- [Capture pane output](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/capture.md)
- [PowerShell common parameters](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.4)

## Examples

Example 1

Use a previously selected native $pane on an endpoint you own.

[Source example](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/Send-TmuxKey.md).

```powershell
$pane | LibTmux\Send-TmuxKey -Key @('C-a', 'Enter') -Confirm:$false
```

## Parameters

- `Pane` (`LibTmux.Pane`): The native pane selected from the endpoint you intend to change.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `Key` (`System.String[]`): Key tokens in sending order. Use an array for a sequence and quote tokens
such as 'C-a'. This command does not split one string on whitespace.
  Required. Position 1. Does not accept pipeline input. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0). [`ValidateCount(1, 2147483647)`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatecountattribute?view=powershellsdk-7.4.0).
- `Verbose` (`System.Management.Automation.SwitchParameter`): Display verbose messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `vb`.
- `Debug` (`System.Management.Automation.SwitchParameter`): Display debug messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `db`.
- `ErrorAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to non-terminating errors.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ea`.
- `WarningAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to warning messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wa`.
- `InformationAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles information messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `infa`.
- `ProgressAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles progress updates.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `proga`.
- `ErrorVariable` (`System.String`): Store the command's error records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ev`.
- `WarningVariable` (`System.String`): Store the command's warning records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wv`.
- `InformationVariable` (`System.String`): Store the command's information records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `iv`.
- `OutVariable` (`System.String`): Save output in the named variable while passing it down the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ov`.
- `OutBuffer` (`System.Int32`): Buffer output before passing it to the next pipeline command.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ob`.
- `PipelineVariable` (`System.String`): Make the most recent output object available through a named variable within the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `pv`.
- `WhatIf` (`System.Management.Automation.SwitchParameter`): Describe the intended input operation without acquiring or sending anything.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `wi`.
- `Confirm` (`System.Management.Automation.SwitchParameter`): Prompts for confirmation before sending input.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `cf`.

## Returns

`None`: No success objects are emitted. An empty owner pipeline performs no work.
