views:

201

answers:

3

Question says it all - is there a class somewhere in Windows Forms that has the same functionality as the WPF System.Windows.Input.Keyboard? Or am I stuck always having to handle the keyboard events and keep my own state? (I'm specifically interested in a Forms analogue to IsKeyDown).

Alternatively, is there a no-fuss way to use this WPF functionality in my Forms project (I'm not very familiar with WPF, but this looks fussy)?

+1  A: 

I don't believe there is an equivalent for WinForms. The best I know of is the static ModifierKeys property on Control but that is almost certainly not what you are looking for.

I believe you are stuck with handling the events and keeping your own state :(

JaredPar
A: 

Why do you need it? and why can't you simply use Windows.Input.Keyboard in your WinForms application? They are not incompatible, and can be used together. The only reason I can think of is that you need to target .NET 2.x platform and the client machines do not have .NET 3.x installed.

Dennis Roche
See the "fuss" part of my original question and included link - using both WPF and WinForms functionality simultaneously is non-trivial it would appear.
Not Sure
+1  A: 

If you are not averse to P/Invoke, you may want to take a look at the Windows API GetKeyState function.

Volte