I found the origin of the problem. A bug occurs when 2 arrows keys are pressed at the same time. The character then instantly teleport 2 tiles away.