Principles of use
Knowing when to use which types of events is important even in this design. Let's say, for example, that you only want a callback to be called once for a binding that involves the left shift and the R key. You wouldn't define both the event types as Keyboard
, because that would keep invoking the callback method as long as these keys are down. You also don't want to define both of them as KeyDown
events, because that would mean that both of these events would have to be registered at the same time, which, when holding down multiple keys, is likely not going to happen because of the screen refresh rate. The correct way to use this is mixing the Keyboard
and KeyDown
events so that the very last key to be pressed is the KeyDown
type and the rest of the keys will be Keyboard
types. In our example, it means that we would have the left shift key being checked through the sf::Keyboard
class, while the R key would default to an event being dispatched. That might sound odd at first...