SFML community forums
Help => Window => Topic started by: OrientatedCookie on April 24, 2015, 05:19:12 pm
-
How do I check if a letter is pressed down? I try to do it with if
(sf::Keyboard::isKeyPressed(sf::Keyboard::1))
but it says it expected an identifier. How can I do this?
-
Use the right enum (http://www.sfml-dev.org/documentation/2.2/classsf_1_1Keyboard.php#acb4cacd7cc5802dec45724cf3314a142)? Such as sf::Keyboard::Key::NumX or sf::Keyboard::Key::NumpadX, where X is the number you want.
-
is it possible to detect if two numbers have been pressed in one line of code?
-
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Num1) && sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Num2))
{
//code here
}
This should do it. Of course you can replace 1 and 2 with whatever you want, or use Numpad instead of Num like Rosme said if you want.