When do we use keep + to inf and keep + ing? I searched on the internet and did not find anything really accurate and precise on the topic.
We use the verb keep with the present participle to emphasize that the ongoing action persists or persisted (or that it should persist, if the verb is in the imperative).
I warned him to stop, but he kept walking out onto the thin ice.
When you feel discouraged, keep trying.
When long distance runners "hit the wall", they must summon the fortitude to keep running.
At the theater, only a rude idiot keeps talking after the movie has begun.