KeyboardKey Class

A key of a keyboard: the values of the attributes of its keyboard events (https://w3c.github.io/uievents/#keyboardevent).

public sealed class KeyboardKey : IEquatable<KeyboardKey>
Implements

Constructors

NameDescription
KeyboardKey(string)Creates a key whose code, legacy key code, location and text are derived from its key value, as the keys of a US keyboard.

KeyboardKey(string)

UserInput.Keyboard.cs

Creates a key whose code, legacy key code, location and text are derived from its key value, as the keys of a US keyboard.

public KeyboardKey(string key)

Parameters

key string
The key value (https://w3c.github.io/uievents-key/): a character (e.g. a, A, 1, ?) or the name of a key (e.g. Enter, Shift, ArrowLeft, F1).

Properties

NameDescription
CodeGets the physical key (the code attribute of the events, https://w3c.github.io/uievents-code/), e.g. KeyA, or the empty string.
KeyGets the key value (the key attribute of the events, https://w3c.github.io/uievents-key/).
KeyCodeGets the legacy virtual key code (the keyCode attribute of the keydown and keyup events), or 0.
LocationGets the location of the key on the keyboard (the location attribute of the events): 0 standard, 1 left, 2 right, 3 numeric keypad.
TextGets the text that the key inserts in the editable content (the keypress event is fired when it is not empty), e.g. the character of the key, or \r for the Enter key; empty for a key that inserts no text.

Gets the physical key (the code attribute of the events, https://w3c.github.io/uievents-code/), e.g. KeyA, or the empty string.

public string Code { get; init; }

Property value

string

Gets the key value (the key attribute of the events, https://w3c.github.io/uievents-key/).

public string Key { get; init; }

Property value

string

Gets the legacy virtual key code (the keyCode attribute of the keydown and keyup events), or 0.

public uint KeyCode { get; init; }

Property value

uint

Gets the location of the key on the keyboard (the location attribute of the events): 0 standard, 1 left, 2 right, 3 numeric keypad.

public uint Location { get; init; }

Property value

uint

Gets the text that the key inserts in the editable content (the keypress event is fired when it is not empty), e.g. the character of the key, or \r for the Enter key; empty for a key that inserts no text.

public string Text { get; init; }

Property value

string

Methods

NameDescription
Equals(KeyboardKey?)
Equals(object?)
GetHashCode()
ToString()

Equals overloads

Equals(KeyboardKey?)

public bool Equals(KeyboardKey? other)
Parameters
other KeyboardKey?
Returns

bool

No documentation is available.

Equals(object?)

public override bool Equals(object? obj)
Parameters
obj object?
Returns

bool

No documentation is available.

GetHashCode()

public override int GetHashCode()

Returns

int

No documentation is available.

ToString()

public override string ToString()

Returns

string

No documentation is available.

Operators

NameDescription
operator ==(KeyboardKey?, KeyboardKey?)
operator !=(KeyboardKey?, KeyboardKey?)

operator ==(KeyboardKey?, KeyboardKey?)

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

Parameters

left KeyboardKey?
right KeyboardKey?

Returns

bool

No documentation is available.

operator !=(KeyboardKey?, KeyboardKey?)

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

Parameters

left KeyboardKey?
right KeyboardKey?

Returns

bool

No documentation is available.