Hi there,
i just started to mess around with keyboard input. And i try to figure out a nice and clean way to get keyboardinput for some sort of typing game.
So i figured out how to filter the input a bit and how to get the inputs in need. But the problem i get is, that my mouse also produces keyboard input. These appear to be pretty random.
But the interesting thing is, that only produces input, when the mouse is on the left quarter of the SFML window.
I'm confused and not sure if this intentional. Any ideas?
Also: Do you think 'textentered' is the best solution when i need keyboardinput key by key for a typing game?
Here is the complete code i'm experimenting with:
#include <iostream>
#include "SFML\Graphics.hpp"
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML works!");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (sf::Event::TextEntered)
{
if (event.text.unicode >= 32 && event.text.unicode <= 128)
{
std::cout << "ASCII character typed: " << static_cast<char>(event.text.unicode) << std::endl;
}
}
}
window.clear();
window.display();
}
return 0;
}