KeyRoutedEventArgs class

Applies to Windows and Windows Phone

Provides data for the KeyUp and KeyDown routed events, as well as related attached and Preview events.

Inheritance

Object
  RoutedEventArgs
    KeyRoutedEventArgs

Syntax

Public NotInheritable Class KeyRoutedEventArgs
    Inherits RoutedEventArgs

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

Members

The KeyRoutedEventArgs class has these types of members:

Methods

The KeyRoutedEventArgs class inherits methods from the Object class.

Properties

The KeyRoutedEventArgs class has these properties.

PropertyAccess typeDescription

Handled

Read/writeGets or sets a value that marks the routed event as handled. A true value for Handled prevents most handlers along the event route from handling the same event again.

Key

Read-onlyGets the keyboard key associated with the event.

KeyStatus

Read-onlyGets a structure value that reports various system-detected characteristics of the key press, including repeat count and menu status.

OriginalSource

Read-onlyGets a reference to the object that raised the event. (Inherited from RoutedEventArgs)

 

Examples

The following example code demonstrates the use of this type. For the complete code listing, see the XAML WebView control sample.

Private Sub NavigateButton_Click(sender As Object, e As RoutedEventArgs)
    ProgressRing1.IsActive = True

    ' Provide an indication as to where we are trying to navigate to
    rootPage.NotifyUser(String.Format("Navigating to: {0}", Address.Text), NotifyType.StatusMessage)

    ' Hook the LoadCompleted event for the WebView to know when the URL is fully loaded
    AddHandler WebView1.LoadCompleted, AddressOf WebView1_LoadCompleted

    ' Attempt to navigate to the specified URL.  Notice that a malformed URL will raise a FormatException
    ' which we catch and let the user know that the URL is bad and to enter a new well-formed one.
    Try
        Dim targetUri As New Uri(Address.Text)
        WebView1.Navigate(targetUri)
    Catch myE As FormatException
        ' Bad address
        rootPage.NotifyUser(String.Format("Address is invalid, try again.  Details --> {0}", myE.Message), NotifyType.ErrorMessage)
    End Try
End Sub

Private Sub WebView1_LoadCompleted(sender As Object, e As Windows.UI.Xaml.Navigation.NavigationEventArgs)
    WebView1.Visibility = Windows.UI.Xaml.Visibility.Visible
    BlockingRect.Visibility = Windows.UI.Xaml.Visibility.Collapsed
    ProgressRing1.IsActive = False

    ' Tell the user that the page has loaded
    rootPage.NotifyUser("Page loaded", NotifyType.StatusMessage)
End Sub

Private Sub Address_KeyUp(sender As Object, e As Object)
    'If e.Key = Windows.System.VirtualKey.Enter Then
    '    NavigateButton_Click(Me, New RoutedEventArgs())
    'End If
End Sub

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Input
Windows::UI::Xaml::Input [C++]

Metadata

Windows.winmd

See also

RoutedEventArgs
WebView
XAML WebView control sample

 

 

Show:
© 2014 Microsoft. All rights reserved.