
Question:
This question already has an answer here:
- How to detect the currently pressed key? 11 answers
I have a need to determine if a key is currently being pressed. I do not need an event to fire, I simply need to determine if a key is being pressed to decide a code path. I looked around and there are some great GlobalKeyHook classes however they are event based.
Little example, basically I need to determine if the user is holding a key down when my app starts and if so then the app does one thing, other wise it starts up as normal. Does anyone have any idea's?
Solution:1
Look at this post, if you encounter problems to check the keyboard-state at app-startup.
Get keyboard status in WPF Application in Main-Method during startup
Check the second eldest post, there is shown how to make it with DLLImport
Solution:2
No sooner did I post the question then I found the answer. This post was what I needed. How to detect the currently pressed key?
Thanks Patrick
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon