# AspireTerminalKey Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md)
- Kind: `Methods`
- Members: `9`

Represents one terminal keypress, optionally combined with modifiers, for [AspireTerminal.SendKeyAsync(AspireTerminalKey, CancellationToken)](/reference/api/csharp/aspire.hosting/aspireterminal/methods.md#sendkeyasync-aspireterminalkey-cancellationtoken).

<a id="alt"></a>
<a id="alt-aspireterminalkey"></a>

## Alt(AspireTerminalKey)

- Name: `Alt(AspireTerminalKey)`
- Modifiers: `static`
- Returns: [AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting/ApplicationModel/AspireTerminalKey.cs#L314-L316)

Adds the Alt modifier to a terminal keypress.

```csharp
public struct AspireTerminalKey
{
    public static AspireTerminalKey Alt(
        AspireTerminalKey key)
    {
        // ...
    }
}
```

## Parameters

- `key` ([AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md))
  The initialized keypress, including any existing modifiers.

## Returns

[AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md) -- A keypress with Alt added, preserving its key identity and other modifiers.

## Exceptions

- `ArgumentException` -- `key` is default-initialized.

## Remarks

Repeated application has no additional effect, and composition with other modifiers is order-independent.

<a id="ctrl"></a>
<a id="ctrl-aspireterminalkey"></a>

## Ctrl(AspireTerminalKey)

- Name: `Ctrl(AspireTerminalKey)`
- Modifiers: `static`
- Returns: [AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting/ApplicationModel/AspireTerminalKey.cs#L286-L288)

Adds the Control modifier to a terminal keypress.

```csharp
public struct AspireTerminalKey
{
    public static AspireTerminalKey Ctrl(
        AspireTerminalKey key)
    {
        // ...
    }
}
```

## Parameters

- `key` ([AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md))
  The initialized keypress, including any existing modifiers.

## Returns

[AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md) -- A keypress with Control added, preserving its key identity and other modifiers.

## Exceptions

- `ArgumentException` -- `key` is default-initialized.

## Remarks

Repeated application has no additional effect, and composition with other modifiers is order-independent.

<a id="equals"></a>
<a id="equals-aspireterminalkey"></a>

## Equals(AspireTerminalKey)

- Name: `Equals(AspireTerminalKey)`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting/ApplicationModel/AspireTerminalKey.cs#L324)

Determines whether another keypress has the same key identity and modifiers.

```csharp
public struct AspireTerminalKey
{
    public bool Equals(
        AspireTerminalKey other)
    {
        // ...
    }
}
```

## Parameters

- `other` ([AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md))
  The keypress to compare.

## Returns

`bool` -- `true` if the key identities and modifiers are equal; otherwise, `false`.

<a id="equals-object"></a>

## Equals(object?)

- Name: `Equals(object?)`
- Modifiers: `override`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting/ApplicationModel/AspireTerminalKey.cs#L331)

Determines whether an object is a keypress with the same key identity and modifiers.

```csharp
public struct AspireTerminalKey
{
    public override bool Equals(
        object? obj)
    {
        // ...
    }
}
```

## Parameters

- `obj` (`object?`)
  The object to compare, or `null`.

## Returns

`bool` -- `true` if the object is an equal keypress; otherwise, `false`.

<a id="gethashcode"></a>

## GetHashCode

- Name: `GetHashCode`
- Modifiers: `override`
- Returns: `int`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting/ApplicationModel/AspireTerminalKey.cs#L337)

Gets a hash code based on the key identity and modifiers.

```csharp
public struct AspireTerminalKey
{
    public override int GetHashCode()
    {
        // ...
    }
}
```

## Returns

`int` -- The hash code for this keypress.

<a id="op-equality"></a>
<a id="op-equality-aspireterminalkey-aspireterminalkey"></a>

## op_Equality(AspireTerminalKey, AspireTerminalKey)

- Name: `op_Equality(AspireTerminalKey, AspireTerminalKey)`
- Modifiers: `static`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting/ApplicationModel/AspireTerminalKey.cs#L366)

Determines whether two keypresses have the same key identity and modifiers.

```csharp
public struct AspireTerminalKey
{
    public static bool operator ==(
        AspireTerminalKey left,
        AspireTerminalKey right)
    {
        // ...
    }
}
```

## Parameters

- `left` ([AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md))
  The first keypress.
- `right` ([AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md))
  The second keypress.

## Returns

`bool` -- `true` if the keypresses are equal; otherwise, `false`.

<a id="op-inequality"></a>
<a id="op-inequality-aspireterminalkey-aspireterminalkey"></a>

## op_Inequality(AspireTerminalKey, AspireTerminalKey)

- Name: `op_Inequality(AspireTerminalKey, AspireTerminalKey)`
- Modifiers: `static`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting/ApplicationModel/AspireTerminalKey.cs#L374)

Determines whether two keypresses differ in key identity or modifiers.

```csharp
public struct AspireTerminalKey
{
    public static bool operator !=(
        AspireTerminalKey left,
        AspireTerminalKey right)
    {
        // ...
    }
}
```

## Parameters

- `left` ([AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md))
  The first keypress.
- `right` ([AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md))
  The second keypress.

## Returns

`bool` -- `true` if the keypresses differ; otherwise, `false`.

<a id="shift"></a>
<a id="shift-aspireterminalkey"></a>

## Shift(AspireTerminalKey)

- Name: `Shift(AspireTerminalKey)`
- Modifiers: `static`
- Returns: [AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting/ApplicationModel/AspireTerminalKey.cs#L300-L302)

Adds the Shift modifier to a terminal keypress.

```csharp
public struct AspireTerminalKey
{
    public static AspireTerminalKey Shift(
        AspireTerminalKey key)
    {
        // ...
    }
}
```

## Parameters

- `key` ([AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md))
  The initialized keypress, including any existing modifiers.

## Returns

[AspireTerminalKey](/reference/api/csharp/aspire.hosting/aspireterminalkey.md) -- A keypress with Shift added, preserving its key identity and other modifiers.

## Exceptions

- `ArgumentException` -- `key` is default-initialized.

## Remarks

Repeated application has no additional effect, and composition with other modifiers is order-independent.

<a id="tostring"></a>

## ToString

- Name: `ToString`
- Modifiers: `override`
- Returns: `string`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting/ApplicationModel/AspireTerminalKey.cs#L348-L357)

Gets a readable description of this keypress.

```csharp
public struct AspireTerminalKey
{
    public override string ToString()
    {
        // ...
    }
}
```

## Returns

`string` -- The named key prefixed by any modifiers in Ctrl, Alt, Shift order, separated by `+`, or `Uninitialized` for a default-initialized value.
