UserForm KeyDown, KeyUp, KeyPress events

Hello, everybody,

Please help me to set F12 to run macro, when UserForm is active.

Problem description:
Assume F12 is assigned to run macro OpenForm() and OpenForm() show UserForm:

Sub OpenForm()
End Sub

I want F12 to show UserForm. When UserForm is visible/active, pressing F12 must hide or unload UserForm. In other words F12 must show/hide UserForm alternatively.

Problem is that when UserForm is active, F12 not work. KeyDown, KeyPress, KeyUp events not work or work only as control events. But my form has more than 30 controls and it is difficult to write event codes KeyDown, KeyPress, KeyUp to capture F12 pressing for every control and for every new added controls.

All will be fine if KeyDown, KeyPress, KeyUp events worked on UserForm level.

Please help me to work around this problem.