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. 或者, 使用 helper 屬性IsUpIsDownIsToggled來判斷指定的索引鍵為啟動、關閉或切換。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

取得屬於廢鍵組合 (Dead Key Composition) 之一部分的按鍵,以建立單一組合 (Combined) 字元。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)

適用於

另請參閱