Key capture at low level

I have an application that uses Hot Keys to activate various functions. The user can choose pretty much any key and the shift parameters to go with it.

The keys are checked via the Application.OnMessage handler (WM_KEYDOWN and WM_KEYUP), but F10 (menu focus) is not seen there.

While I can capture F10 in the OnKeyDown (with KeyPreview set) on the main form, that doesn’t help when other forms have the focus and I didn’t want to have to add that code to every form.

Is there a better way to capture the keys at a lower level than Application.OnMessage ?

This might be at a lower level that you want to go but have you considered/looked at SetWindowsHookEx ?

Hi David,

For F10, you have to trap WM_SYSCOMMAND with wParam = SC_KEYMENU. It is amazing how badly written and confusing the MS docs are! Have a look here -

Hope that helps, Tony

Thanks guys, I’ll look into both of those. :slight_smile:

1 Like

From 2008, I think … A Key’s Odyssey - Peter Below.

1 Like