Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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:

Show:
© 2015 Microsoft