Represents the keyboard device.
Assembly: PresentationCore (in PresentationCore.dll)
Thetype exposes the following members.
|DefaultRestoreFocusMode||Gets or sets the behavior of Windows Presentation Foundation (WPF) when restoring focus.|
|FocusedElement||Gets the element that has keyboard focus.|
|Modifiers||Gets the set of ModifierKeys that are currently pressed.|
|PrimaryDevice||Gets the primary keyboard input device.|
|GotKeyboardFocus||Occurs when an element receives keyboard focus.|
|KeyboardInputProviderAcquireFocus||Occurs when the keyboard input provider acquires focus.|
|KeyDown||Occurs when a key on the keyboard is pressed.|
|KeyUp||Occurs when a key on the keyboard is released.|
|LostKeyboardFocus||Occurs when an element loses keyboard focus.|
|PreviewGotKeyboardFocus||Occurs when an element is in the process of acquiring keyboard focus.|
|PreviewKeyboardInputProviderAcquireFocus||Occurs when the keyboard input provider is in the process of acquiring focus.|
|PreviewKeyDown||Occurs when a key on the keyboard is pressed.|
|PreviewKeyUp||Occurs when a key on the keyboard is released.|
|PreviewLostKeyboardFocus||Occurs when an element is in the process of losing keyboard focus.|
|GotKeyboardFocusEvent||Identifies the Keyboard.GotKeyboardFocus attached event.|
|KeyboardInputProviderAcquireFocusEvent||Identifies the Keyboard.KeyboardInputProviderAcquireFocus attached event.|
|KeyDownEvent||Identifies the Keyboard.KeyDown attached event.|
|KeyUpEvent||Identifies the Keyboard.KeyUp attached event.|
|LostKeyboardFocusEvent||Identifies the Keyboard.LostKeyboardFocus attached event.|
|PreviewGotKeyboardFocusEvent||Identifies the Keyboard.PreviewGotKeyboardFocus attached event.|
|PreviewKeyboardInputProviderAcquireFocusEvent||Identifies the Keyboard.PreviewKeyboardInputProviderAcquireFocus attached event.|
|PreviewKeyDownEvent||Identifies the Keyboard.PreviewKeyDown attached event.|
|PreviewKeyUpEvent||Identifies the Keyboard.PreviewKeyUp attached event.|
|PreviewLostKeyboardFocusEvent||Identifies the Keyboard.PreviewLostKeyboardFocus attached event.|
The class provides keyboard-related events, methods, and properties that provide information regarding the state of the keyboard.
Each of the events that defines as an attached event is also re-exposed by the base element classes UIElement and ContentElement as a new routed event. Generally, it is more convenient to handle keyboard events for an application on UIElement and ContentElement, rather than using the events. For details, see Input Overview.
In order for an element to receive keyboard input, the element must be focusable. Most UIElement derived objects are focusable by default. Otherwise, to make an element focusable, set the Focusable property on the base element to true. For more information on the base elements, see Base Elements Overview.
Keyboard focus refers to the object that is receiving keyboard input. The element with keyboard focus has IsKeyboardFocused set to true. There can be only one element with keyboard focus on the entire desktop. Logical focus refers to the object within a focus scope that has focus. For more information on focus, keyboard focus, and logical focus, see Input Overview and Focus Overview.
The static members of the class delegate to the primary KeyboardDevice of the calling thread, so they are not necessarily thread-safe.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)