Key Enumeration

Specifies the possible key values on a keyboard.

Namespace: System.Windows.Input
Assembly: WindowsBase (in windowsbase.dll)
XML Namespace:

public enum Key
/** @attribute TypeConverterAttribute(System.Windows.Input.KeyConverter) */ 
public enum Key
public enum Key
<object property="EnumerationValue" .../>

 Member nameDescription
AThe A key.  
AbntC1The ABNT_C1 (Brazilian) key.  
AbntC2The ABNT_C2 (Brazilian) key.  
AddThe Add key.  
AppsThe Application key (Microsoft Natural Keyboard).  
AttnThe ATTN key.  
BThe B key.  
Back The Backspace key.  
BrowserBackThe Browser Back key.  
BrowserFavoritesThe Browser Favorites key.  
BrowserForwardThe Browser Forward key.  
BrowserHomeThe Browser Home key.  
BrowserRefreshThe Browser Refresh key.  
BrowserSearchThe Browser Search key.  
BrowserStopThe Browser Stop key.  
CThe C key.  
CancelThe Cancel key.  
Capital The Caps Lock key.  
CapsLock The Caps Lock key.  
Clear The Clear key.  
CrSelThe CRSEL key.  
DThe D key.  
D0The F0 key.  
D1The F1 key.  
D2 The F2 key.  
D3 The F3 key.  
D4 The F4 key.  
D5 The F5 key.  
D6 The F6 key.  
D7 The F7 key.  
D8 The F8 key.  
D9 The F9 key.  
DbeAlphanumericThe DBE_ALPHANUMERIC key.  
DbeCodeInputThe DBE_CODEINPUT key.  
DbeDbcsCharThe DBE_DBCSCHAR key.  
DbeDetermineStringThe DBE_DETERMINESTRING key.  
DbeEnterDialogConversionModeThe DBE_ENTERDLGCONVERSIONMODE key.  
DbeEnterImeConfigureModeThe DBE_ENTERIMECONFIGMODE key.  
DbeEnterWordRegisterModeThe DBE_ENTERWORDREGISTERMODE key.  
DbeFlushStringThe DBE_FLUSHSTRING key.  
DbeHiraganaThe DBE_HIRAGANA key.  
DbeKatakanaThe DBE_KATAKANA key.  
DbeNoCodeInputThe DBE_NOCODEINPUT key.  
DbeNoRomanThe DBE_NOROMAN key.  
DbeRomanThe DBE_ROMAN key.  
DbeSbcsCharThe DBE_SBCSCHAR key.  
DecimalThe Decimal key.  
Delete The Delete key.  
DivideThe Divide key.  
Down The Down Arrow key.  
EThe E key.  
End The End key.  
Enter The Enter key.  
EraseEofThe ERASE EOF key.  
Escape The ESC key.  
Execute The Execute key.  
ExSelThe EXSEL key.  
FThe F key.  
F1The F1 key.  
F10The F10 key.  
F11The F11 key.  
F12The F12 key.  
F13The F13 key.  
F14The F14 key.  
F15The F15 key.  
F16The F16 key.  
F17The F17 key.  
F18The F18 key.  
F19The F19 key.  
F2The F2 key.  
F20The F20 key.  
F21The F21 key.  
F22The F22 key.  
F23The F23 key.  
F24The F24 key.  
F3The F3 key.  
F4The F4 key.  
F5The F5 key.  
F6The F6 key.  
F7The F7 key.  
F8The F8 key.  
F9The F9 key.  
FinalMode The IME Final mode key.  
GThe G key.  
HThe H key.  
HangulMode The IME Hangul mode key.  
HanjaMode The IME Hanja mode key.  
Help The Help key.  
Home The Home key.  
IThe I key.  
ImeAccept The IME Accept key.  
ImeConvert The IME Convert key.  
ImeModeChange The IME Mode change request.  
ImeNonConvert The IME NonConvert key.  
ImeProcessedA special key masking the real key being processed by an IME.  
Insert The Insert key.  
JThe J key.  
JunjaMode The IME Junja mode key.  
KThe K key.  
KanaMode The IME Kana mode key.  
KanjiMode The IME Kanji mode key.  
LThe L key.  
LaunchApplication1The Launch Application1 key.  
LaunchApplication2The Launch Application2 key.  
LaunchMailThe Launch Mail key.  
Left The Left Arrow key.  
LeftAltThe left ALT key.  
LeftCtrlThe left CTRL key.  
LeftShiftThe left Shift key.  
LineFeed The Linefeed key.  
LWinThe left Windows logo key (Microsoft Natural Keyboard).  
MThe M key.  
MediaNextTrackThe Media Next Track key.  
MediaPlayPauseThe Media Play Pause key.  
MediaPreviousTrackThe Media Previous Track key.  
MediaStopThe Media Stop key.  
MultiplyThe Multiply key.  
NThe N key.  
Next The Page Down key.  
NoNameA constant reserved for future use.  
NoneNo key pressed.  
NumLockThe Num Lock key.  
NumPad0The 0 key on the numeric keypad.  
NumPad1The 1 key on the numeric keypad.  
NumPad2The 2 key on the numeric keypad.  
NumPad3The 3 key on the numeric keypad.  
NumPad4The 4 key on the numeric keypad.  
NumPad5The 5 key on the numeric keypad.  
NumPad6The 6 key on the numeric keypad.  
NumPad7The 7 key on the numeric keypad.  
NumPad8The 8 key on the numeric keypad.  
NumPad9The 9 key on the numeric keypad.  
OThe O key.  
Oem1The OEM 1 key.  
Oem102The OEM 102 key.  
Oem2The OEM 2 key.  
Oem3The OEM 3 key.  
Oem4The OEM 4 key.  
Oem5The OEM 5 key.  
Oem6The OEM 6 key.  
Oem7The OEM 7 key.  
Oem8The OEM 8 key.  
OemAttnThe OEM ATTN key.  
OemAutoThe OEM AUTO key.  
OemBackslashThe OEM Backslash key.  
OemBackTabThe OEM BACKTAB key.  
OemClearThe OEM Clear key.  
OemCloseBracketsThe OEM Close Brackets key.  
OemCommaThe OEM Comma key.  
OemCopyThe OEM COPY key.  
OemEnlwThe OEM ENLW key.  
OemFinishThe OEM FINISH key.  
OemMinusThe OEM Minus key.  
OemOpenBracketsThe OEM Open Brackets key.  
OemPeriodThe OEM Period key.  
OemPipeThe OEM Pipe key.  
OemPlusThe OEM Addition key.  
OemQuestionThe OEM Question key.  
OemQuotesThe OEM Quotes key.  
OemSemicolonThe OEM Semicolon key.  
OemTildeThe OEM Tilde key.  
PThe P key.  
Pa1The PA1 key.  
PageDown The Page Down key.  
PageUp The Page Up key.  
Pause The Pause key.  
PlayThe PLAY key.  
Print The Print key.  
PrintScreen The Print Screen key.  
Prior The Page Up key.  
QThe Q key.  
RThe R key.  
Return The Return key.  
Right The Right Arrow key.  
RightAltThe right ALT key.  
RightCtrlThe right CTRL key.  
RightShiftThe right Shift key.  
RWinThe right Windows logo key (Microsoft Natural Keyboard).  
SThe S key.  
ScrollThe Scroll Lock key.  
Select The Select key.  
SelectMediaThe Select Media key.  
SeparatorThe Separator key.  
SleepThe Computer Sleep key.  
Snapshot The Print Screen key.  
Space The Spacebar key.  
SubtractThe Subtract key.  
SystemA special key masking the real key being processed as a system key.  
TThe T key.  
Tab The Tab key.  
UThe U key.  
Up The Up Arrow key.  
VThe V key.  
VolumeDownThe Volume Down key.  
VolumeMuteThe Volume Mute key.  
VolumeUpThe Volume Up key.  
WThe W key.  
XThe X key.  
YThe Y key.  
ZThe Z key.  
ZoomThe ZOOM key.  

Information pertaining to key input can be obtained in several different ways in WPF. Key related events, such as KeyDown and KeyUp, provide key state information through the KeyEventArgs object which is passed to the event handler. Key state information can also be obtained through the static methods on the Keyboard class, such as IsKeyUp and GetKeyStates. The Keyboard class reports the current state of the keyboard.

This example shows how to detect when the Enter key is pressed on the keyboard.

This example consists of a Extensible Application Markup Language (XAML) file and a code-behind file. For the complete samples, see Keyboard Key Sample.

When the user presses the Enter key in the TextBox, the input in the text box appears in another area of the user interface (UI).

The following XAML creates the user interface, which consists of a StackPanel, a TextBlock, and a TextBox.

  <TextBlock Width="300" Height="20">
    Type some text into the TextBox and press the Enter key.
  <TextBox Width="300" Height="30" Name="textBox1"
  <TextBlock Width="300" Height="100" Name="textBlock1"/>

The following code behind creates the KeyDown event handler. If the key that is pressed is the Enter key, a message is displayed in the TextBlock.

private void OnKeyDownHandler(object sender, KeyEventArgs e)
    if (e.Key == Key.Return)
        textBlock1.Text = "You Entered: " + textBox1.Text;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0