UIElement.PreviewKeyDown 事件

定義

發生于 UIElement 有焦點時按下鍵盤按鍵時。

public:
 virtual event KeyEventHandler ^ PreviewKeyDown;
// Register
event_token PreviewKeyDown(KeyEventHandler const& handler) const;

// Revoke with event_token
void PreviewKeyDown(event_token const* cookie) const;

// Revoke with event_revoker
UIElement::PreviewKeyDown_revoker PreviewKeyDown(auto_revoke_t, KeyEventHandler const& handler) const;
public event KeyEventHandler PreviewKeyDown;
function onPreviewKeyDown(eventArgs) { /* Your code */ }
uIElement.addEventListener("previewkeydown", onPreviewKeyDown);
uIElement.removeEventListener("previewkeydown", onPreviewKeyDown);
- or -
uIElement.onpreviewkeydown = onPreviewKeyDown;
Public Custom Event PreviewKeyDown As KeyEventHandler 
<uiElement PreviewKeyDown="eventhandler"/>

事件類型

Windows 需求

裝置系列
Windows 10 Fall Creators Update (已於 10.0.16299.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v5.0 引進)

備註

PreviewKeyDown 是路由事件。 如需路由事件概念的詳細資訊,請參閱 事件和路由事件概觀

此事件會使用通道路由策略。 對應的反升事件是 KeyDown

適用於

另請參閱