How to detect KeyPress while program is running in background in Win32 C++
You need to set up a keyboard hook using SetWindowsHookEx(). Look at the WH_KEYBOARD and WH_KEYBOARD_LL hooks.
If you know exactly what keystroke you're expecting, you can use RegisterHotkey
and Windows will send you a message when that key is pressed.
If you want to detect all keystrokes, @OJ's answer will work.