Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

KeyEventArgs class

Contains the arguments returned by a virtual key event.

Syntax


Public NotInheritable Class KeyEventArgs
    Implements ICoreWindowEventArgs

Members

The KeyEventArgs class has these types of members:

Methods

The KeyEventArgs class inherits methods from the Object class.

Properties

The KeyEventArgs class has these properties.

PropertyAccess typeDescription

Handled

Read/writeGets or sets whether the key press event was handled.

KeyStatus

Read-onlyGets the status of a key at the time the event is fired.

VirtualKey

Read-onlyGets the virtual key that maps to the key that was pressed.

 

Remarks

Windows 10:  

Apps do not receive this event when an Input Method Editor (IME) is enabled. The IME handles all keyboard input and sets Handled to true.

Windows Phone:  

This API is supported in native apps only.

This object is returned by a delegate registered for one of the following events:



// returning keypress events data through KeyEventArgs

void MyCoreWindowEvents::SetWindow( // implementation called by CoreApplication::Run(), provided for context
    _In_ CoreWindow^ window
    )
{
    // ...
    window->KeyDown +=
        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &CoreWindowEvents::OnKeyDown);
    window->KeyUp +=
        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &CoreWindowEvents::OnKeyUp);

    // ...
   
}


Note  : This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX).
 

Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.UI.Core
Windows::UI::Core [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8

Namespace

Windows.UI.Core
Windows::UI::Core [C++]

Metadata

Windows.winmd

Attributes

[MarshalingBehavior(Standard)]
[Version(0x06020000)]
[WebHostHidden()]

See also

Object
ICoreWindowEventArgs
KeyDown
KeyUp

 

 

Show:
© 2015 Microsoft