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:
- Z for an English (QWERTY) layout
- W for a French (AZERTY) layout
- Y for a German (QWERTZ) layout
- Z for a Russian (JCUKEN) layout
Definition
Namespace: Avalonia.Input
Assembly: Avalonia.Base (in Avalonia.Base.dll)
- C#
- VB
- F#
public Key Key { get; init; }
Public Property Key As Key
Get
Set
member Key : Key with get, set
Property Value
KeyRemarks
This property should be used for letter-related shortcuts only.
Prefer using 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 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
Reference
KeyEventArgs Class
Avalonia.Input Namespace
PhysicalKey
KeySymbol