Key Enumeration
Specifies the possible key values on a keyboard.
Assembly: WindowsBase (in WindowsBase.dll)
| Member name | Description | |
|---|---|---|
| None | No key pressed. | |
| Cancel | The Cancel key. | |
| Back | The Backspace key. | |
| Tab | The Tab key. | |
| LineFeed | The Linefeed key. | |
| Clear | The Clear key. | |
| Return | The Return key. | |
| Enter | The Enter key. | |
| Pause | The Pause key. | |
| Capital | The Caps Lock key. | |
| CapsLock | The Caps Lock key. | |
| KanaMode | The IME Kana mode key. | |
| HangulMode | The IME Hangul mode key. | |
| JunjaMode | The IME Junja mode key. | |
| FinalMode | The IME Final mode key. | |
| HanjaMode | The IME Hanja mode key. | |
| KanjiMode | The IME Kanji mode key. | |
| Escape | The ESC key. | |
| ImeConvert | The IME Convert key. | |
| ImeNonConvert | The IME NonConvert key. | |
| ImeAccept | The IME Accept key. | |
| ImeModeChange | The IME Mode change request. | |
| Space | The Spacebar key. | |
| Prior | The Page Up key. | |
| PageUp | The Page Up key. | |
| Next | The Page Down key. | |
| PageDown | The Page Down key. | |
| End | The End key. | |
| Home | The Home key. | |
| Left | The Left Arrow key. | |
| Up | The Up Arrow key. | |
| Right | The Right Arrow key. | |
| Down | The Down Arrow key. | |
| Select | The Select key. | |
| The Print key. | ||
| Execute | The Execute key. | |
| Snapshot | The Print Screen key. | |
| PrintScreen | The Print Screen key. | |
| Insert | The Insert key. | |
| Delete | The Delete key. | |
| Help | The Help key. | |
| D0 | The 0 (zero) key. | |
| D1 | The 1 (one) key. | |
| D2 | The 2 key. | |
| D3 | The 3 key. | |
| D4 | The 4 key. | |
| D5 | The 5 key. | |
| D6 | The 6 key. | |
| D7 | The 7 key. | |
| D8 | The 8 key. | |
| D9 | The 9 key. | |
| A | The A key. | |
| B | The B key. | |
| C | The C key. | |
| D | The D key. | |
| E | The E key. | |
| F | The F key. | |
| G | The G key. | |
| H | The H key. | |
| I | The I key. | |
| J | The J key. | |
| K | The K key. | |
| L | The L key. | |
| M | The M key. | |
| N | The N key. | |
| O | The O key. | |
| P | The P key. | |
| Q | The Q key. | |
| R | The R key. | |
| S | The S key. | |
| T | The T key. | |
| U | The U key. | |
| V | The V key. | |
| W | The W key. | |
| X | The X key. | |
| Y | The Y key. | |
| Z | The Z key. | |
| LWin | The left Windows logo key (Microsoft Natural Keyboard). | |
| RWin | The right Windows logo key (Microsoft Natural Keyboard). | |
| Apps | The Application key (Microsoft Natural Keyboard). | |
| Sleep | The Computer Sleep key. | |
| NumPad0 | The 0 key on the numeric keypad. | |
| NumPad1 | The 1 key on the numeric keypad. | |
| NumPad2 | The 2 key on the numeric keypad. | |
| NumPad3 | The 3 key on the numeric keypad. | |
| NumPad4 | The 4 key on the numeric keypad. | |
| NumPad5 | The 5 key on the numeric keypad. | |
| NumPad6 | The 6 key on the numeric keypad. | |
| NumPad7 | The 7 key on the numeric keypad. | |
| NumPad8 | The 8 key on the numeric keypad. | |
| NumPad9 | The 9 key on the numeric keypad. | |
| Multiply | The Multiply key. | |
| Add | The Add key. | |
| Separator | The Separator key. | |
| Subtract | The Subtract key. | |
| Decimal | The Decimal key. | |
| Divide | The Divide key. | |
| F1 | The F1 key. | |
| F2 | The F2 key. | |
| F3 | The F3 key. | |
| F4 | The F4 key. | |
| F5 | The F5 key. | |
| F6 | The F6 key. | |
| F7 | The F7 key. | |
| F8 | The F8 key. | |
| F9 | The F9 key. | |
| F10 | The F10 key. | |
| F11 | The F11 key. | |
| F12 | The F12 key. | |
| F13 | The F13 key. | |
| F14 | The F14 key. | |
| F15 | The F15 key. | |
| F16 | The F16 key. | |
| F17 | The F17 key. | |
| F18 | The F18 key. | |
| F19 | The F19 key. | |
| F20 | The F20 key. | |
| F21 | The F21 key. | |
| F22 | The F22 key. | |
| F23 | The F23 key. | |
| F24 | The F24 key. | |
| NumLock | The Num Lock key. | |
| Scroll | The Scroll Lock key. | |
| LeftShift | The left Shift key. | |
| RightShift | The right Shift key. | |
| LeftCtrl | The left CTRL key. | |
| RightCtrl | The right CTRL key. | |
| LeftAlt | The left ALT key. | |
| RightAlt | The right ALT key. | |
| BrowserBack | The Browser Back key. | |
| BrowserForward | The Browser Forward key. | |
| BrowserRefresh | The Browser Refresh key. | |
| BrowserStop | The Browser Stop key. | |
| BrowserSearch | The Browser Search key. | |
| BrowserFavorites | The Browser Favorites key. | |
| BrowserHome | The Browser Home key. | |
| VolumeMute | The Volume Mute key. | |
| VolumeDown | The Volume Down key. | |
| VolumeUp | The Volume Up key. | |
| MediaNextTrack | The Media Next Track key. | |
| MediaPreviousTrack | The Media Previous Track key. | |
| MediaStop | The Media Stop key. | |
| MediaPlayPause | The Media Play Pause key. | |
| LaunchMail | The Launch Mail key. | |
| SelectMedia | The Select Media key. | |
| LaunchApplication1 | The Launch Application1 key. | |
| LaunchApplication2 | The Launch Application2 key. | |
| Oem1 | The OEM 1 key. | |
| OemSemicolon | The OEM Semicolon key. | |
| OemPlus | The OEM Addition key. | |
| OemComma | The OEM Comma key. | |
| OemMinus | The OEM Minus key. | |
| OemPeriod | The OEM Period key. | |
| Oem2 | The OEM 2 key. | |
| OemQuestion | The OEM Question key. | |
| Oem3 | The OEM 3 key. | |
| OemTilde | The OEM Tilde key. | |
| AbntC1 | The ABNT_C1 (Brazilian) key. | |
| AbntC2 | The ABNT_C2 (Brazilian) key. | |
| Oem4 | The OEM 4 key. | |
| OemOpenBrackets | The OEM Open Brackets key. | |
| Oem5 | The OEM 5 key. | |
| OemPipe | The OEM Pipe key. | |
| Oem6 | The OEM 6 key. | |
| OemCloseBrackets | The OEM Close Brackets key. | |
| Oem7 | The OEM 7 key. | |
| OemQuotes | The OEM Quotes key. | |
| Oem8 | The OEM 8 key. | |
| Oem102 | The OEM 102 key. | |
| OemBackslash | The OEM Backslash key. | |
| ImeProcessed | A special key masking the real key being processed by an IME. | |
| System | A special key masking the real key being processed as a system key. | |
| OemAttn | The OEM ATTN key. | |
| DbeAlphanumeric | The DBE_ALPHANUMERIC key. | |
| OemFinish | The OEM FINISH key. | |
| DbeKatakana | The DBE_KATAKANA key. | |
| OemCopy | The OEM COPY key. | |
| DbeHiragana | The DBE_HIRAGANA key. | |
| OemAuto | The OEM AUTO key. | |
| DbeSbcsChar | The DBE_SBCSCHAR key. | |
| OemEnlw | The OEM ENLW key. | |
| DbeDbcsChar | The DBE_DBCSCHAR key. | |
| OemBackTab | The OEM BACKTAB key. | |
| DbeRoman | The DBE_ROMAN key. | |
| Attn | The ATTN key. | |
| DbeNoRoman | The DBE_NOROMAN key. | |
| CrSel | The CRSEL key. | |
| DbeEnterWordRegisterMode | The DBE_ENTERWORDREGISTERMODE key. | |
| ExSel | The EXSEL key. | |
| DbeEnterImeConfigureMode | The DBE_ENTERIMECONFIGMODE key. | |
| EraseEof | The ERASE EOF key. | |
| DbeFlushString | The DBE_FLUSHSTRING key. | |
| Play | The PLAY key. | |
| DbeCodeInput | The DBE_CODEINPUT key. | |
| Zoom | The ZOOM key. | |
| DbeNoCodeInput | The DBE_NOCODEINPUT key. | |
| NoName | A constant reserved for future use. | |
| DbeDetermineString | The DBE_DETERMINESTRING key. | |
| Pa1 | The PA1 key. | |
| DbeEnterDialogConversionMode | The DBE_ENTERDLGCONVERSIONMODE key. | |
| OemClear | The OEM Clear 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 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. 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.
<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.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.