KeyEventArgs 类

定义

KeyUpKeyDown 路由事件以及相关的附加和预览事件提供数据。Provides data for the KeyUp and KeyDown routed events, as well as related attached and Preview events.

public ref class KeyEventArgs : System::Windows::Input::KeyboardEventArgs
public class KeyEventArgs : System.Windows.Input.KeyboardEventArgs
type KeyEventArgs = class
    inherit KeyboardEventArgs
Public Class KeyEventArgs
Inherits KeyboardEventArgs
继承

注解

此事件数据类与以下附加事件一起使用:This event data class is used with the following attached events:

此事件数据类还与基元素上的以下路由事件一起使用。This event data class is also used with the following routed events on base elements. 这些路由事件转发前面列出的附加事件, 使其更易于访问中WPFWPF的常规元素模型。These routed events forward the previously listed attached events to make them more accessible to the general element model in WPFWPF.

附加事件和基本元素路由事件共享其事件数据, 路由事件的冒泡和隧道版本也共享事件数据。The attached events and the base element routed events share their event data, and the bubbling and tunneling versions of the routed events also share event data. 这可能会影响事件在传输事件路由时的已处理特性。This can affect the handled characteristics of the event as it travels the event route. 有关详细信息, 请参阅输入概述For details, see Input Overview.

键可以同时处于启动和切换状态, 也可以是关闭状态和切换状态。A key can be in both the up and toggled states or the down and toggled states. 出于此原因, 确定键是否向上或向下键不像将KeyStates值作为数值来检查一样简单。For this reason, determining whether a key is up or down is not as simple as checking the KeyStates value as a numeric value. 相反, 应通过将值视为标志枚举来检查值。Instead, you should check the value by treating it as a flag enumeration. 使用第一位的比较。ANDUse an AND comparison of the first bit. 此外, 还可以使用帮助IsUpIsDown属性、 IsToggled和来确定给定键是向上、向下还是已切换。Alternatively, use the helper properties IsUp, IsDown, and IsToggled to determine whether a given key is up, down, or toggled.

构造函数

KeyEventArgs(KeyboardDevice, PresentationSource, Int32, Key)

初始化 KeyEventArgs 类的新实例。Initializes a new instance of the KeyEventArgs class.

属性

DeadCharProcessedKey

获取作为语音符号键构成的一部分以创建一个组合字符的键。Gets the key that is part of dead key composition to create a single combined character.

Device

获取启动此事件的输入设备。Gets the input device that initiated this event.

(继承自 InputEventArgs)
Handled

获取或设置一个值,该值指示针对路由事件(在其经过路由时)的事件处理的当前状态。Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.

(继承自 RoutedEventArgs)
ImeProcessedKey

如果事件引用的键盘键将由 输入法编辑器 (IME)Input Method Editor (IME) 处理,则获取此键。Gets the keyboard key referenced by the event, if the key will be processed by an 输入法编辑器 (IME)Input Method Editor (IME).

InputSource

获取提供此输入的输入源。Gets the input source that provided this input.

IsDown

获取指示事件引用的键是否处于按下状态的值。Gets a value that indicates whether the key referenced by the event is in the down state.

IsRepeat

获取指示事件引用的键盘键是否为重复键的值。Gets a value that indicates whether the keyboard key referenced by the event is a repeated key.

IsToggled

获取指示事件引用的键是否处于切换状态的值。Gets a value that indicates whether the key referenced by the event is in the toggled state.

IsUp

获取指示事件引用的键是否处于松开状态的值。Gets a value that indicates whether the key referenced by the event is in the up state.

Key

获取与事件关联的键盘键。Gets the keyboard key associated with the event.

KeyboardDevice

获取与输入事件关联的键盘设备。Gets the keyboard device associated with the input event.

(继承自 KeyboardEventArgs)
KeyStates

获取与此事件关联的键盘键的状态。Gets the state of the keyboard key associated with this event.

OriginalSource

在父类进行任何可能的 Source 调整之前,获取由纯命中测试确定的原始报告源。Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class.

(继承自 RoutedEventArgs)
RoutedEvent

获取或设置与此 RoutedEventArgs 实例关联的 RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance.

(继承自 RoutedEventArgs)
Source

获取或设置对引发事件的对象的引用。Gets or sets a reference to the object that raised the event.

(继承自 RoutedEventArgs)
SystemKey

如果事件引用的键盘键将由系统处理,则获取此键。Gets the keyboard key referenced by the event, if the key will be processed by the system.

Timestamp

获取此事件发生时的时间。Gets the time when this event occurred.

(继承自 InputEventArgs)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InvokeEventHandler(Delegate, Object)

以特定于类型的方式调用事件处理程序,这样做可以提高事件系统效率。Invokes event handlers in a type-specific way, which can increase event system efficiency.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
OnSetSource(Object)

在派生类中重写时,每当实例的 Source 属性的值发生更改,则提供一个通知回调入口点。When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes.

(继承自 RoutedEventArgs)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅