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

Author Topic: Can't check LControl or RControl  (Read 2962 times)

0 Members and 1 Guest are viewing this topic.

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Can't check LControl or RControl
« on: October 05, 2015, 12:09:29 pm »
Hi

I'm encountering a problem.
I want to check if the user presses the left Control (Ctrl) key.

But it ain't working.
This is my code:
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::LControl) || sf::Keyboard::isKeyPressed(sf::Keyboard::Key::RControl)) {
                                                //SFML Error
                                                switch(character) {
                                                        case 13:
                                                                //Send as FIRST!!!
                                                                cout << "pressed"<<endl;
                                                                break;
                                                }
                                        }

But, what I find weird:
When I replace LControl with "Left", it's working perfectly. It only ain't working with Shift or Alt.

To be more clear, I'm using:
Asus X555LD,
Azerty keyboard-layout,
Windows 8.1,
Visual Studio 2015 Enterprise,
SFML 2.3.2.

It can't be a problem because of if/else-if orders, because I get the exact same result when placing that block on top. So, is this a problem of me, my hardware, or SFML? And how to fix it?

Thanks!

Rhimlock

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Can't check LControl or RControl
« Reply #1 on: October 05, 2015, 12:29:39 pm »
You should not mix pollEvent and isKeyPressed.

In your Key-Event, you have members for "alt", "control" and "shift"

http://www.sfml-dev.org/documentation/2.3.2/structsf_1_1Event_1_1KeyEvent.php

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Can't check LControl or RControl
« Reply #2 on: October 12, 2015, 06:39:34 pm »
It can't be a problem because of if/else-if orders, because I get the exact same result when placing that block on top.
Is LControl tested at all before this if block?

You should not mix pollEvent and isKeyPressed.
There is no pollEvent in this code.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything