C++ Simulate key press and mantain it pressed on Windows : I Have this C++ Function that receives Virtual Key and Press/Release the key:

    void SendKey (WORD wVk, bool press) {
       keybd_event(wVk, 0, press? 0 : KEYEVENTF_KEYUP, 0);
    }

But it does just press the key 1 time, not constantly as i expected.

Im constructing a joypad simulation, so, i need to configure KeyDown and KeyUp respectively, this is a little C++ process that reads by cmd the key and the type (Down, Press or Release):

    #define WINVER 0x0500
    #include <windows.h>
    #include <iostream>

    using namespace std;

    void SendKey (WORD wVk, bool press) {
        keybd_event(wVk, 0, press? 0 : KEYEVENTF_KEYUP, 0);
    }

    void PressKey (WORD wVk) {
        SendKey(wVk, true);
        Sleep(30);
        SendKey(wVk, false);
    }

    int main() {
        int key;
        char type;

        while(true) {
            cin >> key;
            cin >> type;

            if(key == 0) break;
            if(type == 'd') SendKey((WORD) key, true);
            if(type == 'r') SendKey((WORD) key, false);
            if(type == 'p') PressKey((WORD) key);
        }

        return 0;
    }

Thanks a lot, if anyone have built something like this, plz tell me.