SFML has a solid, multi-platform interface for dealing with events, which includes key pressing events. Fairly beginner friendly to follow along, but you should know the basics of the language. https://www.sfml-dev.org/index.php
// while there are pending events...
// check the type of the event...
// window closed
// key pressed
// logic if you press Bbutton:
if (event.key.code == sf::Keyboard::B)
std::cout << "the B key was pressed" << std::endl;
// we don't process other types of events
Edit: But I realize now that SFML might not be what you want, since you're only talking about the console. See the Windows-only section if you're working with windows, otherwise I'm not sure.