Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
Example
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
protected override void OnKeyDown(KeyEventArgs keyg)
{
switch(keyg.KeyData)
{
case Keys.Left:
label1.Text = "Left";
break;
case Keys.Right:
label1.Text = "Right";
break;
case Keys.Down:
label1.Text = "Down";
break;
case Keys.Up:
label1.Text = "Up";
break;
case Keys.Return:
label1.Text = "Return";
break;
default:
break;
}
}
Compiling the Code
This example requires references to the following namespaces:
See Also
Tasks
How to: Use the HardwareButton Component