.NET 4.0+WPF Commanding - Keyboard Shortcuts
The one hundred and sixty-sixth part of the Windows Presentation Foundation Fundamentals tutorial takes another look at WPF commanding. This article describes how keyboard shortcuts can be used to execute commands, using key bindings.
Common Keys
You can detect most keyboard keys using key bindings, though some more advanced keyboards include keys that cannot be included in the Key or Gesture properties. The following tables include the most commonly used keys but the lists are not exhaustive. In each table, the left column specifies the text that should be included in the properties of key bindings. The right column shows the keys that the codes represent.
Basic Keys
Key Code | Key(s) |
---|
A - Z | The basic letter keys. |
D0 - D9 | The numeric keys from the main section of the keyboard. |
Space | The space bar. |
F1 - F24 | The function keys. |
Symbol Keys
Key Code | Key(s) |
---|
OemBackslash | The backslash key (\). |
OemComma | The comma key (,). |
OemPeriod | The full stop (period) key (.). |
OemQuestion | The question mark key (?). |
OemSemicolon | The semicolon key (;). |
OemOpenBrackets | The open bracket key ([). |
OemCloseBrackets | The close bracket key (]). |
OemPlus | The plus key from the main section of the keyboard (+). |
OemMinus | The minus key from the main section of the keyboard (-). |
OemQuotes | The quote key ("). |
OemPipe | The pipe key (|). |
OemTilde | The tilde key (~). |
Oem1 - Oem8 Oem102 | Additional standard keys on the keyboard. These are not defined with readable names, as they vary depending upon the user's keyboard layout. |
Numeric Keypad Keys
Key Code | Key(s) |
---|
NumPad0 - NumPad9 | The numeric keys from the numeric keypad. |
Decimal | The decimal point from the numeric keypad (.). |
Add | The addition key from the numeric keypad (+). |
Subtract | The subtraction key from the numeric keypad (-). |
Multiply | The multiplication key from the numeric keypad (*). |
Divide | The division from the numeric keypad (/). |
Navigation Keys
Key Code | Key(s) |
---|
Up | The up arrow key. |
Down | The down arrow key. |
Left | The left arrow key. |
Right | The right arrow key. |
Home | The Home key. |
End | The End key. |
PageUp | The PageUp / PgUp key. |
PageDown | The PageDown / PgDn key. |
Control Keys
Key Code | Key(s) |
---|
Back | The Backspace key. |
Capital | The Caps Lock key. |
Delete | The Delete key. |
Enter | The Enter key. |
Esc | The Escape / Esc key. |
Insert | The Insert key. |
NumLock | The Num Lock key. |
PrintScreen | The PrintScreen / PrtSc key. |
Return | The Return key. |
Scroll | The Scroll Lock key. |
Tab | The Tab key. |
Browser Keys
Key Code | Key(s) |
---|
BrowserHome | The browser Home key. |
BrowserBack | The browser Back key. |
BrowserForward | The browser Forward key. |
BrowserStop | The browser Stop key. |
BrowserRefresh | The browser Refresh key. |
BrowserFavorites | The browser Favourites key. |
BrowserSearch | The browser Search key. |
Media Keys
Key Code | Key(s) |
---|
MediaPlayPause | The play / pause media key. |
MediaStop | The stop playing media key. |
MediaPreviousTrack | The previous track media key. |
MediaNextTrack | The next track media key. |
Volume Keys
Key Code | Key(s) |
---|
VolumeUp | The increase audio volume key. |
VolumeDown | The decrease audio volume key. |
VolumeMute | The audio mute key. |
Application Keys
Key Code | Key(s) |
---|
LaunchApplication1 | The first application launcher key. |
LaunchApplication2 | The second application launcher key. |
LaunchMail | The email application launcher key. |
18 June 2015