CoreWindow.GetCurrentKeyEventDeviceId 方法

定義

擷取產生此金鑰事件之輸入裝置的唯一識別碼。

所有輸入裝置都不支援 GetCurrentKeyEventDeviceId。

public:
 virtual Platform::String ^ GetCurrentKeyEventDeviceId() = GetCurrentKeyEventDeviceId;
winrt::hstring GetCurrentKeyEventDeviceId();
public string GetCurrentKeyEventDeviceId();
function getCurrentKeyEventDeviceId()
Public Function GetCurrentKeyEventDeviceId () As String

傳回

String

Platform::String

winrt::hstring

與金鑰事件或空字串相關聯的輸入裝置的唯一識別碼。 每次連線時,相同的裝置都可以指派不同的識別碼。

處理索引鍵事件之後,這個方法會傳回空字串。

Windows 需求

裝置系列
Windows 10 Anniversary Edition (已於 10.0.14393.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v3.0 引進)

備註

使用 GetCurrentKeyEventDeviceId 來區分可產生重要事件的裝置,例如多個遊戲控制器。 裝置識別碼適用于將輸入裝置與特定使用者帳戶產生關聯。

若要取得有效的裝置識別碼,您必須從 KeyUpKeyDown 事件處理常式呼叫這個方法。

適用於