Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting menu shortcut to ESC key

Status
Not open for further replies.

trezlub

Programmer
May 2, 2003
67
GB
How can I set a shortcut on a menu to the ESC key? It does not seem to be an option in the list of available shortcuts.

 
Esc key is normally not used as a shortcut key as for a menu item. However, if you want to use it for this purpose, you need to perform these steps.

Place a command button on your form and set its properties as under.
Name = "cmdCancel"
Cancel = True
Left = -1000
TabStop = False

Place the following code in your form.
___
Private Sub cmdCancel_Click()
myMenuItem_Click
End Sub
Private Sub myMenuItem_Click()
MsgBox "myMenuItem_Click"
End Sub
___

And to display "Esc" as a shortcut key in front of the caption of your menu item, insert the following line of code in Form_OnLoad event.
___
myMenuItem.Caption = myMenuItem.Caption & vbTab & "Esc"
___
Note that myMenuItem is the name of the menu item you are interested in. Run the program and test it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top