How do I simulate a keypress

Hi, I would need this exact same function but I don’t know how to program it in C++, can you help me? I need to simulate some keyboard key press…