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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Keyboard Command - F10 and then Enter

Status
Not open for further replies.

UncleCake

Technical User
Feb 4, 2002
355
US
Hi,

For as long as I have worked at the company I work for we have used F10 to do the same function as pressing the Enter button on the keyboard. I have just ran across a situation where if the user presses the F10 and then the next key they press is Enter, it will give a dropdown window that gives the option of restore, move, resize, minimize, maximize, or close.

Is there a way to disable this?

-UncleCake
 
Look at the KeyDown event, which traps keys by their keyboard mapping rather than their ascii values as in KeyPress.

HTH

Bob
 

You need to add the following line to the keydown event to every control on the form in order to ignore the F10 key

If KeyCode = 121 Then KeyCode = 0

Alternatively set the forms KeyPreview property to TRUE and just add it the Forms keydown event.


 
Ooops my solution cancels the F10, to replace it with Enter you probaly need

If KeyCode = 121 Then KeyCode = 13
 
You need to add the following line to the keydown event to every control on the form in order to ignore the F10 key
Actually, you don't need to do that. Just set the KeyPreview property on the Form to true, and then write your code in the Form_KeyDown event handler. This will cause the event to "bubble up" from each control to the form before actually executing the keystroke.

The rules are:

1. KeyUp, KeyDown, and KeyPress are affected.
2. If a control has one of these event handlers, it executes first, followed by the form's handler.
3. If the control event handler cancels the keystroke, the form event handler isn't executed.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top