Expand Minimize

Key Enumeration

Specifies the possible key values on a keyboard.

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

[TypeConverterAttribute(typeof(KeyConverter))]
public enum class Key
<object property="enumerationMemberName" .../>

Member nameDescription
NoneNo key pressed.
CancelThe Cancel key.
BackThe Backspace key.
TabThe Tab key.
LineFeedThe Linefeed key.
ClearThe Clear key.
ReturnThe Return key.
EnterThe Enter key.
PauseThe Pause key.
CapitalThe Caps Lock key.
CapsLockThe Caps Lock key.
KanaModeThe IME Kana mode key.
HangulModeThe IME Hangul mode key.
JunjaModeThe IME Junja mode key.
FinalModeThe IME Final mode key.
HanjaModeThe IME Hanja mode key.
KanjiModeThe IME Kanji mode key.
EscapeThe ESC key.
ImeConvertThe IME Convert key.
ImeNonConvertThe IME NonConvert key.
ImeAcceptThe IME Accept key.
ImeModeChangeThe IME Mode change request.
SpaceThe Spacebar key.
PriorThe Page Up key.
PageUpThe Page Up key.
NextThe Page Down key.
PageDownThe Page Down key.
EndThe End key.
HomeThe Home key.
LeftThe Left Arrow key.
UpThe Up Arrow key.
RightThe Right Arrow key.
DownThe Down Arrow key.
SelectThe Select key.
PrintThe Print key.
ExecuteThe Execute key.
SnapshotThe Print Screen key.
PrintScreenThe Print Screen key.
InsertThe Insert key.
DeleteThe Delete key.
HelpThe Help key.
D0The 0 (zero) key.
D1The 1 (one) key.
D2The 2 key.
D3The 3 key.
D4The 4 key.
D5The 5 key.
D6The 6 key.
D7The 7 key.
D8The 8 key.
D9The 9 key.
AThe A key.
BThe B key.
CThe C key.
DThe D key.
EThe E key.
FThe F key.
GThe G key.
HThe H key.
IThe I key.
JThe J key.
KThe K key.
LThe L key.
MThe M key.
NThe N key.
OThe O key.
PThe P key.
QThe Q key.
RThe R key.
SThe S key.
TThe T key.
UThe U key.
VThe V key.
WThe W key.
XThe X key.
YThe Y key.
ZThe Z key.
LWinThe left Windows logo key (Microsoft Natural Keyboard).
RWinThe right Windows logo key (Microsoft Natural Keyboard).
AppsThe Application key (Microsoft Natural Keyboard).
SleepThe Computer Sleep 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.
MultiplyThe Multiply key.
AddThe Add key.
SeparatorThe Separator key.
SubtractThe Subtract key.
DecimalThe Decimal key.
DivideThe Divide key.
F1The F1 key.
F2The F2 key.
F3The F3 key.
F4The F4 key.
F5The F5 key.
F6The F6 key.
F7The F7 key.
F8The F8 key.
F9The F9 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.
F20The F20 key.
F21The F21 key.
F22The F22 key.
F23The F23 key.
F24The F24 key.
NumLockThe Num Lock key.
ScrollThe Scroll Lock key.
LeftShiftThe left Shift key.
RightShiftThe right Shift key.
LeftCtrlThe left CTRL key.
RightCtrlThe right CTRL key.
LeftAltThe left ALT key.
RightAltThe right ALT key.
BrowserBackThe Browser Back key.
BrowserForwardThe Browser Forward key.
BrowserRefreshThe Browser Refresh key.
BrowserStopThe Browser Stop key.
BrowserSearchThe Browser Search key.
BrowserFavoritesThe Browser Favorites key.
BrowserHomeThe Browser Home key.
VolumeMuteThe Volume Mute key.
VolumeDownThe Volume Down key.
VolumeUpThe Volume Up key.
MediaNextTrackThe Media Next Track key.
MediaPreviousTrackThe Media Previous Track key.
MediaStopThe Media Stop key.
MediaPlayPauseThe Media Play Pause key.
LaunchMailThe Launch Mail key.
SelectMediaThe Select Media key.
LaunchApplication1The Launch Application1 key.
LaunchApplication2The Launch Application2 key.
Oem1The OEM 1 key.
OemSemicolonThe OEM Semicolon key.
OemPlusThe OEM Addition key.
OemCommaThe OEM Comma key.
OemMinusThe OEM Minus key.
OemPeriodThe OEM Period key.
Oem2The OEM 2 key.
OemQuestionThe OEM Question key.
Oem3The OEM 3 key.
OemTildeThe OEM Tilde key.
AbntC1The ABNT_C1 (Brazilian) key.
AbntC2The ABNT_C2 (Brazilian) key.
Oem4The OEM 4 key.
OemOpenBracketsThe OEM Open Brackets key.
Oem5The OEM 5 key.
OemPipeThe OEM Pipe key.
Oem6The OEM 6 key.
OemCloseBracketsThe OEM Close Brackets key.
Oem7The OEM 7 key.
OemQuotesThe OEM Quotes key.
Oem8The OEM 8 key.
Oem102The OEM 102 key.
OemBackslashThe OEM Backslash key.
ImeProcessedA special key masking the real key being processed by an IME.
SystemA special key masking the real key being processed as a system key.
OemAttnThe OEM ATTN key.
DbeAlphanumericThe DBE_ALPHANUMERIC key.
OemFinishThe OEM FINISH key.
DbeKatakanaThe DBE_KATAKANA key.
OemCopyThe OEM COPY key.
DbeHiraganaThe DBE_HIRAGANA key.
OemAutoThe OEM AUTO key.
DbeSbcsCharThe DBE_SBCSCHAR key.
OemEnlwThe OEM ENLW key.
DbeDbcsCharThe DBE_DBCSCHAR key.
OemBackTabThe OEM BACKTAB key.
DbeRomanThe DBE_ROMAN key.
AttnThe ATTN key.
DbeNoRomanThe DBE_NOROMAN key.
CrSelThe CRSEL key.
DbeEnterWordRegisterModeThe DBE_ENTERWORDREGISTERMODE key.
ExSelThe EXSEL key.
DbeEnterImeConfigureModeThe DBE_ENTERIMECONFIGMODE key.
EraseEofThe ERASE EOF key.
DbeFlushStringThe DBE_FLUSHSTRING key.
PlayThe PLAY key.
DbeCodeInputThe DBE_CODEINPUT key.
ZoomThe ZOOM key.
DbeNoCodeInputThe DBE_NOCODEINPUT key.
NoNameA constant reserved for future use.
DbeDetermineStringThe DBE_DETERMINESTRING key.
Pa1The PA1 key.
DbeEnterDialogConversionModeThe DBE_ENTERDLGCONVERSIONMODE key.
OemClearThe OEM Clear key.
DeadCharProcessedThe key is used with another key to create a single combined character.

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 that 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.

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.


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


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.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft