I needed this functionality as well for a Linux program that would respond immediately to user input, and was able to locate it within the cpp-terminal library. Its keys.cpp example shows how the library can immediately react to users' keypresses. I imagine the same code works across platforms, but you'd have to test it out.