How to: Override Smartphone Soft Keys

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

Normally, Smartphone soft keys operate menus; however, you can provide custom soft key functionality by removing the MainMenu component from your form. When there is no menu in a Smartphone application, Soft Key 1 and Soft Key 2 presses raise the KeyDown event followed by a KeyUp event when the keys are released.

The KeyCode field recognizes F1 as Soft Key 1, and F2 as Soft Key 2.

The following code example shows how to provide event handling code for soft key presses.

Visual C# users need to define an event hander for the KeyPress event in the form's constructor.

// Connect an event handler to the KeyPress event
this.KeyPress += new KeyPressEventHandler(OnKeyPress);

Private Sub keypressed(ByVal o As [Object], _
    ByVal e As KeyPressEventArgs) Handles MyBase.KeyPress
     ' Determine if ESC key value is raised.
     If e.KeyChar = ChrW(27) Then
         ' Handle the event to provide your own functionality.
         e.Handled = True

         ' Add  your event handling code here.
         MessageBox.Show("Custom back key functionality.")  
     End If
  End Sub

This example requires references to the following namespaces: