how to simulate a OnKeyDown event

How can I simulate a OnKeyDown event in C++ Builder 4? Basically I want my program to think that I pressed a certain key on the keybord when I click a TButton for example.
TropicalFishAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
nietodConnect With a Mentor Commented:
Often it is best not to even try that.  Instead you should try to move the code that responds to the key to a seperate function.  Then you can call this function when the button is pressed or when the key is typed.  

That is likely to be the best solution.  However, you could use the keybd_event() function to "simulate" the pressing of the key.  This is a windows API function and it is documented in the windows help.  

Let me know if you have any questions.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.