Home > Blog > Simulating key presses in your program with keybd_event function
Simulating key presses in your program with keybd_event function
Oct 11, 2009 | 42Gears Team
Out of need or curiosity you might want to know how to send key presses from your native application. The core of the solution involves calling keybd_event() function which has the following prototype.
bVk is the virtual-key code of the character. bScan is the hardware scan code. dwFlags is an important field. If KEYEVENTF_KEYUP is specified in dwFlags field, the key is being released. If not specified, the key is being pressed.
Here is a function which simulates pressing of alphanumeric characters. See winuser.h for all available virtual key codes.