Jump to content

  • Log In with Google      Sign In   
  • Create Account

Checking is caps lock on in sfml


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 BaneTrapper   Members   -  Reputation: 1201

Like
0Likes
Like

Posted 10 October 2012 - 12:33 PM

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, 10 October 2012 - 12:39 PM.

Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/


Sponsor:

#2 FLeBlanc   Crossbones+   -  Reputation: 3101

Like
1Likes
Like

Posted 10 October 2012 - 01:03 PM

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?

#3 Servant of the Lord   Crossbones+   -  Reputation: 19564

Like
1Likes
Like

Posted 10 October 2012 - 01:08 PM

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).
It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#4 BaneTrapper   Members   -  Reputation: 1201

Like
0Likes
Like

Posted 10 October 2012 - 01:53 PM

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, 10 October 2012 - 01:53 PM.

Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/


#5 wicked357   Members   -  Reputation: 1165

Like
0Likes
Like

Posted 10 October 2012 - 02:09 PM

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.

#6 Dragonsoulj   Crossbones+   -  Reputation: 2111

Like
0Likes
Like

Posted 10 October 2012 - 03:39 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS