Table of Contents

Class Key

Namespace
Bunit
Assembly
Bunit.Web.dll

Representation of keyboard key that can be argument of keyboard events.

public sealed class Key : IEquatable<Key>
Inheritance
Key
Implements
Inherited Members
Extension Methods

Properties

Add

Gets a Key that represents the number pad addition key.

public static Key Add { get; }

Property Value

Key

Alt

Gets a Key that represents the Alt key. This is a control key and it can be combined with other keys. E.g. Key.Enter + Keys.Alt.

public static Key Alt { get; }

Property Value

Key

AltKey

Gets a value indicating whether Alt key is pressed.

public bool AltKey { get; }

Property Value

bool

Backspace

Gets a Key that represents the Backspace key.

public static Key Backspace { get; }

Property Value

Key

Code

Gets the string that identifies the physical key being pressed. The value is not affected by the current keyboard layout or modifier state, so a particular key will always return the same value.

public string Code { get; }

Property Value

string

Command

Gets a Key that represents the function key Command. This is a control key and it can be combined with other keys. E.g. Key.Enter + Key.Command.

public static Key Command { get; }

Property Value

Key

CommandKey

Gets a value indicating whether Command key is pressed.

public bool CommandKey { get; }

Property Value

bool

Control

Gets a Key that represents the Control key. This is a control key and it can be combined with other keys. E.g. Key.Enter + Key.Control.

public static Key Control { get; }

Property Value

Key

ControlKey

Gets a value indicating whether Control key is pressed.

public bool ControlKey { get; }

Property Value

bool

Delete

Gets a Key that represents the Delete key.

public static Key Delete { get; }

Property Value

Key

Divide

Gets a Key that represents the number pad division key.

public static Key Divide { get; }

Property Value

Key

Down

Gets a Key that represents the down arrow key.

public static Key Down { get; }

Property Value

Key

End

Gets a Key that represents the End key.

public static Key End { get; }

Property Value

Key

Enter

Gets a Key that represents the Enter key.

public static Key Enter { get; }

Property Value

Key

Equal

Gets a Key that represents the equal sign key.

public static Key Equal { get; }

Property Value

Key

Escape

Gets a Key that represents the Escape key.

public static Key Escape { get; }

Property Value

Key

F1

Gets a Key that represents the function key F1.

public static Key F1 { get; }

Property Value

Key

F10

Gets a Key that represents the function key F10.

public static Key F10 { get; }

Property Value

Key

F11

Gets a Key that represents the function key F11.

public static Key F11 { get; }

Property Value

Key

F12

Gets a Key that represents the function key F12.

public static Key F12 { get; }

Property Value

Key

F2

Gets a Key that represents the function key F2.

public static Key F2 { get; }

Property Value

Key

F3

Gets a Key that represents the function key F3.

public static Key F3 { get; }

Property Value

Key

F4

Gets a Key that represents the function key F4.

public static Key F4 { get; }

Property Value

Key

F5

Gets a Key that represents the function key F5.

public static Key F5 { get; }

Property Value

Key

F6

Gets a Key that represents the function key F6.

public static Key F6 { get; }

Property Value

Key

F7

Gets a Key that represents the function key F7.

public static Key F7 { get; }

Property Value

Key

F8

Gets a Key that represents the function key F8.

public static Key F8 { get; }

Property Value

Key

F9

Gets a Key that represents the function key F9.

public static Key F9 { get; }

Property Value

Key

Home

Gets a Key that represents the Home key.

public static Key Home { get; }

Property Value

Key

Insert

Gets a Key that represents the Insert key.

public static Key Insert { get; }

Property Value

Key

Left

Gets a Key that represents the left arrow key.

public static Key Left { get; }

Property Value

Key

Multiply

Gets a Key that represents the number pad multiplication key.

public static Key Multiply { get; }

Property Value

Key

NumberPad0

Gets a Key that represents the number pad 0 key.

public static Key NumberPad0 { get; }

Property Value

Key

NumberPad1

Gets a Key that represents the number pad 1 key.

public static Key NumberPad1 { get; }

Property Value

Key

NumberPad2

Gets a Key that represents the number pad 2 key.

public static Key NumberPad2 { get; }

Property Value

Key

NumberPad3

Gets a Key that represents the number pad 3 key.

public static Key NumberPad3 { get; }

Property Value

Key

NumberPad4

Gets a Key that represents the number pad 4 key.

public static Key NumberPad4 { get; }

Property Value

Key

NumberPad5

Gets a Key that represents the number pad 5 key.

public static Key NumberPad5 { get; }

Property Value

Key

NumberPad6

Gets a Key that represents the number pad 6 key.

public static Key NumberPad6 { get; }

Property Value

Key

NumberPad7

Gets a Key that represents the number pad 7 key.

public static Key NumberPad7 { get; }

Property Value

Key

NumberPad8

Gets a Key that represents the number pad 8 key.

public static Key NumberPad8 { get; }

Property Value

Key

NumberPad9

Gets a Key that represents the number pad 9 key.

public static Key NumberPad9 { get; }

Property Value

Key

NumberPadDecimal

Gets a Key that represents the number pad decimal separator key.

public static Key NumberPadDecimal { get; }

Property Value

Key

PageDown

Gets a Key that represents the Page Down key.

public static Key PageDown { get; }

Property Value

Key

PageUp

Gets a Key that represents the Page Up key.

public static Key PageUp { get; }

Property Value

Key

Pause

Gets a Key that represents the Pause key.

public static Key Pause { get; }

Property Value

Key

Right

Gets a Key that represents the right arrow key.

public static Key Right { get; }

Property Value

Key

Shift

Gets a Key that represents the Shift key. This is a control key and it can be combined with other keys. E.g. Key.Enter + Key.Shift.

public static Key Shift { get; }

Property Value

Key

ShiftKey

Gets a value indicating whether Shift key is pressed.

public bool ShiftKey { get; }

Property Value

bool

Space

Gets a Key that represents the Spacebar key.

public static Key Space { get; }

Property Value

Key

Subtract

Gets a Key that represents the number pad subtraction key.

public static Key Subtract { get; }

Property Value

Key

Tab

Gets a Key that represents the Tab key.

public static Key Tab { get; }

Property Value

Key

Up

Gets a Key that represents the up arrow key.

public static Key Up { get; }

Property Value

Key

Value

Gets the key value of the key represented. If the value has a printed representation, this attribute's value is the same as the char attribute.

public string Value { get; }

Property Value

string

Methods

Combine(Key?)

Gets a combination of current key with another key. A key instance can be combined only with Control, Shift, Alt, or Command keys.

public Key Combine(Key? key)

Parameters

key Key

The other key to combine with.

Returns

Key

A new key with combination of Control, Shift, Alt, and Command keys.

Equals(Key?)

Gets the value indicating whether the current object is equal to another object of the same type.

public bool Equals(Key? other)

Parameters

other Key

A key to compare with this object.

Returns

bool

True if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Gets the value indicating whether the current object is equal to another object of the same type.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with this object.

Returns

bool

True if the current object is equal to the other parameter; otherwise, false.

Get(char)

Gets a Key object from specified character.

public static Key Get(char value)

Parameters

value char

The key value.

Returns

Key

Get(string)

Gets a Key object with specified value.

public static Key Get(string value)

Parameters

value string

The key value.

Returns

Key

Get(string, string)

Gets a Key object with specified value and code.

public static Key Get(string value, string code)

Parameters

value string

The key value.

code string

The key code of physical key.

Returns

Key

GetHashCode()

Gets hash code of this object.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Gets a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

WithAltKey(bool)

Gets the key with new value of Alt key.

public Key WithAltKey(bool value)

Parameters

value bool

New value of Alt key.

Returns

Key

The key with new value of Alt key.

WithCommandKey(bool)

Gets the key with new value of Command key.

public Key WithCommandKey(bool value)

Parameters

value bool

New value of Command key.

Returns

Key

The key with new value of Command key.

WithControlKey(bool)

Gets the key with new value of Control key.

public Key WithControlKey(bool value)

Parameters

value bool

New value of Control key.

Returns

Key

The key with new value of Control key.

WithShiftKey(bool)

Gets the key with new value of Shift key.

public Key WithShiftKey(bool value)

Parameters

value bool

New value of Shift key.

Returns

Key

The key with new value of Shift key.

Operators

operator +(Key, Key?)

Gets a combination of 2 key objects. A key instance can be combined only with Control, Shift, Alt, or Command keys.

public static Key operator +(Key x, Key? y)

Parameters

x Key

The first key to combine.

y Key

The second key to combine.

Returns

Key

A new key with combination of Control, Shift, Alt, and Command keys.

operator ==(Key?, Key?)

Gets the value indicating whether 2 instances of Key are equal.

public static bool operator ==(Key? x, Key? y)

Parameters

x Key

The first key to compare.

y Key

The second key to compare.

Returns

bool

True if the instances of Key are equal; otherwise, false.

implicit operator KeyboardEventArgs(Key)

Gets a new Key instance with value of character.

public static implicit operator KeyboardEventArgs(Key key)

Parameters

key Key

The character to convert to Key instance.

Returns

KeyboardEventArgs

The Key instance with character value.

implicit operator Key(char)

Gets a new Key instance with value of character.

public static implicit operator Key(char key)

Parameters

key char

The character to convert to Key instance.

Returns

Key

The Key instance with character value.

implicit operator Key(string)

Gets a new Key instance with value of string object.

public static implicit operator Key(string value)

Parameters

value string

The string value to convert to Key instance.

Returns

Key

The Key instance with the specified value.

operator !=(Key?, Key?)

Gets the value indicating whether 2 instances of Key are different.

public static bool operator !=(Key? x, Key? y)

Parameters

x Key

The first key to compare.

y Key

The second key to compare.

Returns

bool

True if the instances of Key are different; otherwise, false.

Progress Telerik

Premium sponsor: Progress Telerik.

Packt

Editorial support provided by Packt.

.NET Foundation

Supported by the .NET Foundation.