Checking is caps lock on in sfml

Started by
4 comments, last by Dragonsoulj 11 years, 7 months ago
Hello.
How do i check if caps lock is ON or OFF
I cannot find it anywhere is there a way to check if it is on?

sf::Event EventList;
while(obj_AppMain.GETR_Screen().pollEvent(EventList))
{
switch(EventList.type)
{
default:
break;
}
}
Advertisement
Googling turned up this thread, in which the maintainer of SFML said that there is no way to check Caps Lock status in SFML, and there probably won't ever be a way. What is it you are trying to do?
In SFML capslock applies the "shift" modifier; I don't think you can poll the key directly.

However, if your intent is to create formatted text, you could use sf::Event::TextEvent which handles that for you.
Or, when you get sf::Event::KeyEvent, it has a bool shift member variable which can tell you if you need to capitalize the character or not (I think this takes capslock into account).

In SFML capslock applies the "shift" modifier; I don't think you can poll the key directly.

However, if your intent is to create formatted text, you could use sf::Event::TextEvent which handles that for you.
Or, when you get sf::Event::KeyEvent, it has a bool shift member variable which can tell you if you need to capitalize the character or not (I think this takes capslock into account).

Using sf::Event::KeyEvent i get something like "uncatched trown error" at visual studio, At .exe file my program crashes
I googled it and people had same problem, so that's out of option.

Am just doing this

sf::Keyboard::isKeyPressed(sf::Keyboard::LShift) == true

It does not handle Caps lock but, sfml does not handle it as it seems.
For windows you can use this to get the state of caps lock. int i = GetKeyState(0x14); 0 is off. Dont forget to include the windows.h header file.
wicked's example should suffice, and you could even add this to one of the SFML files to handle the event. I do believe they include the windows.h file.

This topic is closed to new replies.

Advertisement