How to: Detect Navigation Keys

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

The example in this topic shows how you can determine when a user presses any one of the four directions on a Pocket PC navigation pad or its Return button. You can extend this example to detect keys on a Pocket PC keyboard accessory.

The following example shows how to get the value of a key by overriding the OnKeyDown method and evaluating the KeyData property.

Protected Overrides Sub OnKeyDown(ByVal keyg As KeyEventArgs) 
        Select Case keyg.KeyData
            Case Keys.Left
                Label1.Text = "Left"
            Case Keys.Right
                Label1.Text = "Right"
            Case Keys.Down
                Label1.Text = "Down"
            Case Keys.Up
                Label1.Text = "Up"
            Case Keys.Return
                Label1.Text = "Return"
            End Select
End Sub

This example requires references to the following namespaces: