Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Caps lock  (Read 9149 times)

0 Members and 1 Guest are viewing this topic.

forrestcupp

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Caps lock
« on: August 04, 2009, 07:39:41 pm »
I noticed there is no Key Code for the caps lock button.  You pretty much have everything but that.  Is there any other cross-platform way to tell if the caps lock key has been pressed?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Caps lock
« Reply #1 on: August 04, 2009, 10:45:25 pm »
Well, caps lock is a modifier which simulates a long press on the shift key. Why would you want to detect presses on this key?
Laurent Gomila - SFML developer

forrestcupp

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Caps lock
« Reply #2 on: August 06, 2009, 03:45:49 pm »
Because I'm creating a text input box.  When people press the caps lock key, they expect their text to be capitalized.  If I have no way of detecting if they press it, I have no way of making it behave like the user would expect.

Basically, my reason for wanting this is the same reason that the key exists.

I can do it using win32, but I was hoping for a cross-platform way to do it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Caps lock
« Reply #3 on: August 06, 2009, 03:49:56 pm »
So you think that you can write an algorithm that outputs the proper character according to what keys have been pressed? Well, you can't. Just use the sf::Event::TextEntered event ;)
Laurent Gomila - SFML developer

forrestcupp

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Caps lock
« Reply #4 on: August 06, 2009, 11:02:57 pm »
I actually already did it using sf::Input.  It will do any printable key on an American keyboard, whether shifted or not.  The only thing missing is caps lock.  If the caps lock thing isn't possible, it's not possible.

The reason I needed to use Input is to simplify the future use of what I'm making.  I didn't want to have to use an Event and an Input both for the same class.  I opted for complex now to make it simple for people to use later.

And I really didn't mean to sound like an ass earlier.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Caps lock
« Reply #5 on: August 07, 2009, 12:02:37 am »
I really think you're using the wrong way. Your code will be so complicated, unmaintainable and limited (you'll only be able to handle the ASCII charset -- what about european or asian people?) to emulate a feature which is natively available.

Anyway, caps lock will most likely not be implemented in SFML, sorry ;)

Quote
And I really didn't mean to sound like an ass earlier.

Who said that?
Laurent Gomila - SFML developer

forrestcupp

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Caps lock
« Reply #6 on: August 07, 2009, 01:01:40 am »
I only have one class that takes text input, so it might be worth it.  Can you point me to any examples on how to use a TextEvent.  I can't seem to find anything.  There's really nothing in that section of the Docs.

Thanks for your help.

Edit:

I found your example in this thread.

I wrote about 150 lines of code to do what I could have done in about 6.  Thank you for your help.

Jibble Sandwich

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Caps lock
« Reply #7 on: December 27, 2017, 11:56:21 pm »
Well, caps lock is a modifier which simulates a long press on the shift key. Why would you want to detect presses on this key?


In case someone wants to bind it to something. Caps lock is a prime pinky key for anyone using WASD, so it's a pretty important thing to support for video game developers. Whats funny is that SFML(at least as of 2.4.2) does trigger a KeyPressed event for caps Lock but the keycode is -1(Unknown). So it works fine as long as the player hasn't bound other unknown keys.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Caps lock
« Reply #8 on: January 03, 2018, 05:15:22 pm »
Please do not necroment threads. This discussion is somewhat outdated. Have a look (and contribute to) https://github.com/SFML/SFML/pull/1235. ;-)
SFML / OS X developer

 

anything