Just a quick simple question. How can i have an infinitely running while with operations here and there, and when the user presses the B key, the while executes break;?
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
sf::Event event;
// while there are pending events...
while (window.pollEvent(event))
{
// check the type of the event...
switch (event.type)
{
// window closed
case sf::Event::Closed:
window.close();
break;
// key pressed
case sf::Event::KeyPressed:
// logic if you press Bbutton:
if (event.key.code == sf::Keyboard::B)
{
std::cout << "the B key was pressed" << std::endl;
}
break;
// we don't process other types of events
default:
break;
}
}
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.