SFML community forums

Help => Window => Topic started by: Riton_Lafouine on May 04, 2020, 04:47:27 pm

Title: Accessing + key with shift= (ascii code 43)
Post by: Riton_Lafouine on May 04, 2020, 04:47:27 pm
Hello,

i tried to post on french forum but it seems that's it is not moving much there.

First, i'm a rookie in sfml and in C++

i successfully set up a event chain and some key are triggering properly what i want. For this program, i need to use + key using the shift= key but this key is not triggering sf::Keyboard::Add

Is there an alternative way of triggering this key or is it just not implemented ? if not, will it be one day ?

Subsidiary question. Is it possible to lock the shift key directly in the program because my program will be executed mostly on laptops that may no have a numpad and almost everything will have to deal with numbers. So the access will be direct on numbers instead of "&é"'(-è_çà".

Thanx by advance for your answers.

RLF
Title: Re: Accessing + key with shift= (ascii code 43)
Post by: Hapax on May 05, 2020, 04:30:06 am
To check a key press that is made by pressing shift with another key, check for the base key and also check its shift status to differentiate between the two.

For example, to check plus on the equals key within an event loop:
if (event.key.code == sf::Keyboard::Equals && event.key.shift)
{
    plusWasPressed = true;
}
Title: Re: Accessing + key with shift= (ascii code 43)
Post by: Riton_Lafouine on May 05, 2020, 12:49:16 pm
Really cool,

thanx, i'll try that ! Anything about locking Shift in the program ?

RLF
Title: Re: Accessing + key with shift= (ascii code 43)
Post by: Hapax on May 05, 2020, 11:24:43 pm
You can also check to see if shift is pressed or released in the same way as any other key. To use a form of locking, you can just use a boolean to keep track, swapping whenever it's pressed (or released)

One thing to note is that each shift key is separate so you'd need to check both.