Skip to end of metadata
Go to start of metadata

Represents the keyboard device.

Definition

public static class Keyboard

Summary

The following table summarizes the members exposed in this class.

Static Properties

FocusedElement Gets the element that has keyboard focus.
LastFocusedElement Gets the last element that has keyboard focus.
LastKeyDown Gets the last key that received by the keyboard device.
LastKeyUp Gets the last pressed key that received by the keyboaerd device.
Modifiers Gets the set of ModifierKeys that are currently pressed.

Fields

GotKeyboardFocusEvent Identifies the GotKeyboardFocus routed event.
KeyDownEvent Identifies the KeyDown routed event.
KeyUpEvent Identifies the KeyUp routed event.
LostKeyboardFocusEvent Identifies the LostKeyboardFocus routed event.
PreviewGotKeyboardFocusEvent Identifies the PreviewGotKeyboardFocus routed event.
PreviewKeyDownEvent Identifies the PreviewKeyDown routed event.
PreviewKeyUpEvent Identifies the PreviewKeyUp routed event.
PreviewLostKeyboardFocusEvent Identifies the PreviewLostKeyboardFocus routed event.

Static Methods


Static Properties

public static object FocusedElement { get; }

Gets the element that has keyboard focus.

public static Control LastFocusedElement { get; }

Gets the last element that has keyboard focus.

public static Key LastKeyDown { get; }

Gets the last key that received by the keyboard device.

public static Key LastKeyUp { get; }

Gets the last pressed key that received by the keyboaerd device.

public static ModifierKeys Modifiers { get; }

Gets the set of ModifierKeys that are currently pressed.

Fields

public static readonly RoutedEvent GotKeyboardFocusEvent

Identifies the GotKeyboardFocus routed event.

public static readonly RoutedEvent KeyDownEvent

Identifies the KeyDown routed event.

public static readonly RoutedEvent KeyUpEvent

Identifies the KeyUp routed event.

public static readonly RoutedEvent LostKeyboardFocusEvent

Identifies the LostKeyboardFocus routed event.

public static readonly RoutedEvent PreviewGotKeyboardFocusEvent

Identifies the PreviewGotKeyboardFocus routed event.

public static readonly RoutedEvent PreviewKeyDownEvent

Identifies the PreviewKeyDown routed event.

public static readonly RoutedEvent PreviewKeyUpEvent

Identifies the PreviewKeyUp routed event.

public static readonly RoutedEvent PreviewLostKeyboardFocusEvent

Identifies the PreviewLostKeyboardFocus routed event.

Static Methods

public static void AddGotKeyboardFocusHandler(DependencyObject element, KeyboardFocusChangedEventHandler handler)

Parameters

element
handler

public static void AddKeyDownHandler(DependencyObject element, KeyEventHandler handler)

Parameters

element
handler

public static void AddKeyUpHandler(DependencyObject element, KeyEventHandler handler)

Parameters

element
handler

public static void AddLostKeyboardFocusHandler(DependencyObject element, KeyboardFocusChangedEventHandler handler)

Parameters

element
handler

public static void AddPreviewGotKeyboardFocusHandler(DependencyObject element, KeyboardFocusChangedEventHandler handler)

Parameters

element
handler

public static void AddPreviewKeyDownHandler(DependencyObject element, KeyEventHandler handler)

Parameters

element
handler

public static void AddPreviewKeyUpHandler(DependencyObject element, KeyEventHandler handler)

Parameters

element
handler

public static void AddPreviewLostKeyboardFocusHandler(DependencyObject element, KeyboardFocusChangedEventHandler handler)

Parameters

element
handler

public static Control Focus(Control element)

Parameters

element

public static object GetKeyStates(Key key)

Parameters

key

public static bool IsKeyDown(Key key)

Parameters

key

public static bool IsKeyToggled(Key key)

Parameters

key

public static bool IsKeyUp(Key key)

Parameters

key

public static void RemoveGotKeyboardFocusHandler(DependencyObject element, KeyboardFocusChangedEventHandler handler)

Parameters

element
handler

public static void RemoveKeyDownHandler(DependencyObject element, KeyEventHandler handler)

Parameters

element
handler

public static void RemoveKeyUpHandler(DependencyObject element, KeyEventHandler handler)

Parameters

element
handler

public static void RemoveLostKeyboardFocusHandler(DependencyObject element, KeyboardFocusChangedEventHandler handler)

Parameters

element
handler

public static void RemovePreviewGotKeyboardFocusHandler(DependencyObject element, KeyboardFocusChangedEventHandler handler)

Parameters

element
handler

public static void RemovePreviewKeyDownHandler(DependencyObject element, KeyEventHandler handler)

Parameters

element
handler

public static void RemovePreviewKeyUpHandler(DependencyObject element, KeyEventHandler handler)

Parameters

element
handler

public static void RemovePreviewLostKeyboardFocusHandler(DependencyObject element, KeyboardFocusChangedEventHandler handler)

Parameters

element
handler
  • No labels