CPP Obtenha pressionamento apenas no console

HWND hwnd = GetConsoleWindow();


if (GetForegroundWindow() == hwnd){
    if((GetKeyState(VK_SPACE) & 0x8000) != 0)){
      // DO YOUR STUFF HERE
    }
}
Rich Rattlesnake