SFML community forums
Help => System => Topic started by: Anasky on December 20, 2014, 11:50:52 am
-
Hey everyone,
Recently I implemented the SFML keyboard system, but I'm having issues detecting special keys such as !@#$%^&*. Those keys are on shift on my particular keyboard, but I'm well aware that they are on different locations on different keyboards (for example: it's on 8 without shift in Belgium).
Is there any universal way to detect the special keys, preferably by ASCII code?
Thanks in advance,
Anasky
-
SFML currently has some issues with special characters and will improve on it in the future, see issue #7 (https://github.com/SFML/SFML/issues/7).
If you want text input, use the TextEntered event.
-
I'm already using the SFML events for regular text, as well as enters etc. Only issue is the special characters. Any idea how long it'll take for issue #7 to be fixed?
-
You should be aware that there is a difference between sf::Event::KeyPressed events and sf::Event::TextEntered events.
-
} else if (event.type == sf::Event::TextEntered){
unsigned char t = event.key.code;
KeyDown(event.text.unicode);
} else if (event.type == sf::Event::KeyPressed){
unsigned int keycode = event.key.code;
if (keycode == 88){
if (sf::Keyboard::isKeyPressed(sf::Keyboard::LAlt) || sf::Keyboard::isKeyPressed(sf::Keyboard::RAlt)){
Main.StopLooping = true;
running = false;
}
}
if (keycode == 27 || keycode == 49 || keycode == 52 || keycode == 57 || (keycode >= 71 && keycode <= 74)){
SpecialKeyDown(event.key.code);
}
Yeah, I know :) But as you can see, I have to check for specific keycodes in the KeyPressed for ! etc, but I know that won't work on different keyboards :(