# How to stop diagonally in an event driven input system?

Example scenario:

Assume 2 dimensional top down movement system.

Given that I have 4 directional keys ( UP / DOWN / LEFT / RIGHT ), I am able to move in 8 different directions 4 perpendicular and 4 diagonal.

As long as a directional key is pressed there exists an assumed movement, if all directional keys are released then movement is assumed to have stopped.

If I have an event driven input system in place (instead of polling for key states every frame there is an observer which receives and acts upon events based on which keys are pressed and released) is it possible to stop movement in a diagonal direction given that the events received will be sequential?

In a polling driven input system, as long as I would be able to release both keys fast enough for them both to register as released at the same time on the next frame there would be no need to change the direction and the movement would conclude in a diagonal state.

• You don't want to allow diagonal movement? It's not clear to me what's stopping your from doing that. – MichaelHouse Aug 16 '16 at 19:31
• @Byte56 Given that I have 8 directions an entity can face, I want to be also able to have the entity face diagonally when it stops moving. If I have event driven input, one of the key releases will come before the other effectively setting the direction of the entity to a perpendicular state (i.e. north/east/south/west) before receiving the second release event which will trigger the halt of movement. In effect the entity will always face either up, left, right or down but never in any of the diagonal directions. And I was wondering if its possible for it to do so in some way. – Ceiling Gecko Aug 16 '16 at 19:57
• Polling event systems can also suffer from this problem, if the polling rate is so high that it's very hard for humans to release both keys within the polling period. – congusbongus Sep 16 '16 at 1:19