|  |  | 
              
              | 
                  | Title | Convert Enter and Escape keys to Tab and Shift-Tab for easy navigation in Visual Basic .NET | 
|---|
 | Description | This example shows how to convert Enter and Escape keys to Tab and Shift-Tab for easy navigation in Visual Basic .NET. | 
|---|
 | Keywords | Tab, Enter, Escape, Tab key, Enter key, Escape key, dialog | 
|---|
 | Categories | Miscellany, Software Engineering | 
|---|
 |  | 
 |  | Thanks to Luis XV. 
Override the form's ProcessDialogKey function. When you see an Enter or Escape key, process a Tab or Shift-Tab key instead. This lets the user navigate through fields by pressing Enter and Escape in addition to Tab and Shift-Tab.
               |  | 
 |  
                | ' Convert Enter and Escape keys
' into Tab and Shift-Tab.
' Thanks to Luis XV (luisxvarg@hotmail.com).
Protected Overloads Overrides Function _
    ProcessDialogKey(ByVal keyData As Keys) As Boolean
    Select Case keyData
        Case Keys.Enter
            Return MyBase.ProcessDialogKey(Keys.Tab)
        Case Keys.Escape
            Return MyBase.ProcessDialogKey(Keys.Shift Or _
                Keys.Tab)
    End Select
    Return MyBase.ProcessDialogKey(keyData)
End Function |  |  |  |   |  |  |  |  |