This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Windows Presentation Foundation
.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 CodeKey(s)
A - ZThe basic letter keys.
D0 - D9The numeric keys from the main section of the keyboard.
SpaceThe space bar.
F1 - F24The function keys.

Symbol Keys

Key CodeKey(s)
OemBackslashThe backslash key (\).
OemCommaThe comma key (,).
OemPeriodThe full stop (period) key (.).
OemQuestionThe question mark key (?).
OemSemicolonThe semicolon key (;).
OemOpenBracketsThe open bracket key ([).
OemCloseBracketsThe close bracket key (]).
OemPlusThe plus key from the main section of the keyboard (+).
OemMinusThe minus key from the main section of the keyboard (-).
OemQuotesThe quote key (").
OemPipeThe pipe key (|).
OemTildeThe tilde key (~).
Oem1 - Oem8
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 CodeKey(s)
NumPad0 - NumPad9The numeric keys from the numeric keypad.
DecimalThe decimal point from the numeric keypad (.).
AddThe addition key from the numeric keypad (+).
SubtractThe subtraction key from the numeric keypad (-).
MultiplyThe multiplication key from the numeric keypad (*).
DivideThe division from the numeric keypad (/).

Navigation Keys

Key CodeKey(s)
UpThe up arrow key.
DownThe down arrow key.
LeftThe left arrow key.
RightThe right arrow key.
HomeThe Home key.
EndThe End key.
PageUpThe PageUp / PgUp key.
PageDownThe PageDown / PgDn key.

Control Keys

Key CodeKey(s)
BackThe Backspace key.
CapitalThe Caps Lock key.
DeleteThe Delete key.
EnterThe Enter key.
EscThe Escape / Esc key.
InsertThe Insert key.
NumLockThe Num Lock key.
PrintScreenThe PrintScreen / PrtSc key.
ReturnThe Return key.
ScrollThe Scroll Lock key.
TabThe Tab key.

Browser Keys

Key CodeKey(s)
BrowserHomeThe browser Home key.
BrowserBackThe browser Back key.
BrowserForwardThe browser Forward key.
BrowserStopThe browser Stop key.
BrowserRefreshThe browser Refresh key.
BrowserFavoritesThe browser Favourites key.
BrowserSearchThe browser Search key.

Media Keys

Key CodeKey(s)
MediaPlayPauseThe play / pause media key.
MediaStopThe stop playing media key.
MediaPreviousTrackThe previous track media key.
MediaNextTrackThe next track media key.

Volume Keys

Key CodeKey(s)
VolumeUpThe increase audio volume key.
VolumeDownThe decrease audio volume key.
VolumeMuteThe audio mute key.

Application Keys

Key CodeKey(s)
LaunchApplication1The first application launcher key.
LaunchApplication2The second application launcher key.
LaunchMailThe email application launcher key.
18 June 2015