KeyEventArgs
KeyEventArgs
KeyEventArgs
KeyEventArgs
Class
Definition
Contains the arguments returned by a virtual key event.
public : sealed class KeyEventArgs : ICoreWindowEventArgs, IKeyEventArgs, IKeyEventArgs2public sealed class KeyEventArgs : ICoreWindowEventArgs, IKeyEventArgs, IKeyEventArgs2Public NotInheritable Class KeyEventArgs Implements ICoreWindowEventArgs, IKeyEventArgs, IKeyEventArgs2// This API is not available in Javascript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Remarks
Windows 10 Apps do not receive this event when an Input Method Editor (IME) is enabled. The Input Method Editor (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).
Properties
DeviceId DeviceId DeviceId DeviceId
Gets a unique ID for the input device that generated this key event.
Use DeviceId to differentiate between devices that can generate key events, such as multiple Xbox controllers.
DeviceId is not supported for all input devices.
public : PlatForm::String DeviceId { get; }public string DeviceId { get; }Public ReadOnly Property DeviceId As string// This API is not available in Javascript.
- Value
- PlatForm::String string string string
A unique identifier for the input device associated with the key event, or an empty string. The same device can be assigned a different ID each time it is connected.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
This property is useful for retrieving info for a specific user account associated with the input device.
Handled Handled Handled Handled
Gets or sets whether the key press event was handled.
public : PlatForm::Boolean Handled { get; set; }public bool Handled { get; set; }Public ReadWrite Property Handled As bool// This API is not available in Javascript.
- Value
- PlatForm::Boolean bool bool bool
True if the key press event has been handled by the appropriate delegate; false if it has not.
Remarks
Windows 10 Apps do not receive this event when an Input Method Editor (IME) is enabled. The Input Method Editor (IME) handles all keyboard input and sets Handled to true.
Windows Phone This API is supported in native apps only.
KeyStatus KeyStatus KeyStatus KeyStatus
Gets the status of a key at the time the event is fired.
public : CorePhysicalKeyStatus KeyStatus { get; }public CorePhysicalKeyStatus KeyStatus { get; }Public ReadOnly Property KeyStatus As CorePhysicalKeyStatus// This API is not available in Javascript.
The status of the key.
Remarks
Windows 10 Apps do not receive this event when an Input Method Editor (IME) is enabled. The Input Method Editor (IME) handles all keyboard input and sets Handled to true.
Windows Phone This API is supported in native apps only.
VirtualKey VirtualKey VirtualKey VirtualKey
Gets the virtual key that maps to the key that was pressed.
public : VirtualKey VirtualKey { get; }public VirtualKey VirtualKey { get; }Public ReadOnly Property VirtualKey As VirtualKey// This API is not available in Javascript.
The virtual key value.
Remarks
Windows 10 Apps do not receive this event when an Input Method Editor (IME) is enabled. The Input Method Editor (IME) handles all keyboard input and sets Handled to true.
Windows Phone This API is supported in native apps only.