• Advertisement
Sign in to follow this  

Checking is caps lock on in sfml

This topic is 1931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
}
}
Edited by BaneTrapper

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

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. Edited by BaneTrapper

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement