I use library SFML.

#include <SFML/Window.hpp> #include <SFML/Graphics.hpp> #include <SFML/System.hpp> #include <iostream> int main() { sf::RenderWindow app(sf::VideoMode(800, 600), "test"); bool running = true; while(running) { std::cout << app.GetInput().IsKeyDown(sf::Key::Left) << "\n"; } app.Display(); return 0; 

}

No matter how much I press the button to the left, only 0 appears on the screen. The window is in focus. What is the reason? OC - ​​Linux.

    1 answer 1

    Well, it's time to answer your question. No matter how many developers declare "realtime input", receiving events should be all the same. Therefore, before using the IsKeyDown and similar methods, you need to get the events. That is, in this case, the following must be added to the loop before calling the method: sf :: Event Event; app.GetEvent (Event); That's all.