KeyEventArgs Class
Definition
Provides information specific to a keyboard event.
public class KeyEventArgs
Constructors
| Name | Description |
|---|---|
| KeyEventArgs | No summary available. |
KeyEventArgs Constructor
public KeyEventArgs()
Properties
| Name | Description |
|---|---|
| Key | Gets the virtual-key for the associated event. A given physical key can result in different virtual keys depending on the current keyboard layout. This is the key that is generally referred to when creating keyboard shortcuts. |
| KeyDeviceType | Type of the device that fire the event |
| KeyModifiers | No summary available. |
| KeySymbol | Gets the unicode symbol of the key, or null if none is applicable. |
| PhysicalKey | Gets the physical key for the associated event. |
| Handled | Gets or sets a value indicating whether the routed event has already been handled. Inherited from RoutedEventArgs. |
| Route | Gets or sets the routing strategy (direct, bubbling, or tunneling) of the routed event. Inherited from RoutedEventArgs. |
| RoutedEvent | Gets or sets the routed event associated with these event args. Inherited from RoutedEventArgs. |
| Source | Gets or sets the source object that raised the routed event. Inherited from RoutedEventArgs. |
Key Property
Gets the virtual-key for the associated event. A given physical key can result in different virtual keys depending on the current keyboard layout. This is the key that is generally referred to when creating keyboard shortcuts.
For example, when pressing the key located at the Z position on standard US English QWERTY keyboard,
this property returns:
- Avalonia.Input.Key.Z for an English (QWERTY) layout
- Avalonia.Input.Key.W for a French (AZERTY) layout
- Avalonia.Input.Key.Y for a German (QWERTZ) layout
- Avalonia.Input.Key.Z for a Russian (JCUKEN) layout
public Avalonia.Input.Key Key { get; set; }
Remarks
This property should be used for letter-related shortcuts only. Prefer using Avalonia.Input.KeyEventArgs.PhysicalKey if you need to refer to a key given its position on the keyboard (a common usage is moving the player with WASD-like keys in games), or Avalonia.Input.KeyEventArgs.KeySymbol if you want to know which character the key will output. Avoid using this for shortcuts related to punctuation keys, as they differ wildly depending on keyboard layouts.
See also
KeyDeviceType Property
Type of the device that fire the event
public Avalonia.Input.KeyDeviceType KeyDeviceType { get; set; }
KeyModifiers Property
public Avalonia.Input.KeyModifiers KeyModifiers { get; set; }
KeySymbol Property
Gets the unicode symbol of the key, or null if none is applicable.
For example, when pressing the key located at the Z position on standard US English QWERTY keyboard,
this property returns:
zfor an English (QWERTY) layoutwfor a French (AZERTY) layoutyfor a German (QWERTZ) layoutяfor a Russian (JCUKEN) layout
public string KeySymbol { get; set; }
PhysicalKey Property
Gets the physical key for the associated event.
This value is independent of the current keyboard layout and usually correspond to the key printed on a standard US English QWERTY keyboard.
public Avalonia.Input.PhysicalKey PhysicalKey { get; set; }
Remarks
Use this property if you need to refer to a key given its position on the keyboard (a common usage is moving the player with WASD-like keys).