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

Author Topic: Accessing + key with shift= (ascii code 43)  (Read 3558 times)

0 Members and 1 Guest are viewing this topic.

Riton_Lafouine

  • Newbie
  • *
  • Posts: 16
    • View Profile
Accessing + key with shift= (ascii code 43)
« 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

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Accessing + key with shift= (ascii code 43)
« Reply #1 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;
}
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Riton_Lafouine

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Accessing + key with shift= (ascii code 43)
« Reply #2 on: May 05, 2020, 12:49:16 pm »
Really cool,

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

RLF

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Accessing + key with shift= (ascii code 43)
« Reply #3 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything