Table of Contents

Class KeyGesture

Namespace
Avalonia.Input
Assembly
Avalonia.Base.dll

Defines a keyboard input combination.

public sealed class KeyGesture : IEquatable<KeyGesture>, IFormattable
Inheritance
KeyGesture
Implements
Inherited Members

Constructors

KeyGesture(Key, KeyModifiers)

public KeyGesture(Key key, KeyModifiers modifiers = KeyModifiers.None)

Parameters

key Key
modifiers KeyModifiers

Properties

Key

public Key Key { get; }

Property Value

Key

KeyModifiers

public KeyModifiers KeyModifiers { get; }

Property Value

KeyModifiers

Methods

Equals(KeyGesture?)

public bool Equals(KeyGesture? other)

Parameters

other KeyGesture

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

Matches(KeyEventArgs?)

public bool Matches(KeyEventArgs? keyEvent)

Parameters

keyEvent KeyEventArgs

Returns

bool

Parse(string)

public static KeyGesture Parse(string gesture)

Parameters

gesture string

Returns

KeyGesture

ToString()

public override string ToString()

Returns

string

ToString(string?, IFormatProvider?)

Returns the current KeyGesture as a string formatted according to the format string and appropriate IFormatProvider

public string ToString(string? format, IFormatProvider? formatProvider)

Parameters

format string

The format to use.

  • null or "" or "g"The Invariant format, uses Enum.ToString() to format Keys.
  • "p"Use platform specific formatting as registerd.
formatProvider IFormatProvider

The IFormatProvider to use. If null, uses the appropriate provider registered in the Avalonia Locator, or Invariant.

Returns

string

The formatted string.

Exceptions

FormatException

Thrown if the format string is not null, "", "g", or "p"

Operators

operator ==(KeyGesture?, KeyGesture?)

public static bool operator ==(KeyGesture? left, KeyGesture? right)

Parameters

left KeyGesture
right KeyGesture

Returns

bool

operator !=(KeyGesture?, KeyGesture?)

public static bool operator !=(KeyGesture? left, KeyGesture? right)

Parameters

left KeyGesture
right KeyGesture

Returns

bool