I
I
IliaNeverov2021-06-12 10:51:50
C++ / C#
IliaNeverov, 2021-06-12 10:51:50

How to implement a response to key combinations?

How in SFML for two simultaneously pressed keys to perform an action so that actions for each of the keys are not performed separately?

For example:

if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)) {
  function1();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) {
  function2();
}

How to call function 3 when s and d are pressed, but without calling function 1 and function 2?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2021-06-12
@IliaNeverov

if (S && D) {
  functino3();
} else if (S) {
  function1();
} else if (D) {
  function2();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question