Search code examples
c#winformsonkeyup

Detect keyup on winform without any control


As stated in title, I have a form that doesn't have any control on itself (so I can't focus it!!! damn).

I keep it controlless because I need to show images on background and I need to move it by keeping mouse clicked.

Are there any way to detect the keyup event when this is the foreground window?should I use a global hook (and check which is the foreground image obviusly)?

Any simplier workaround?I tested with an hidden control but it's not working.

The problem of putting a control with opacity = 0 brings the possibility to "miss" the MouseDown and MouseUp events (because they could happen over the control instead of the form, but I can still redirect them)

Any suggestion?

Here is the question where I picked some resources: Fire Form KeyPress event


Solution

  • Can't you just set the Form's KeyPreview to true and use the Form's KeyUp Event? (or am i missing something?)