I was (doing something) when (something sudden happened)
This is a very common storytelling technique: you set up a continuous action you were doing, then you tell about a sudden event that happened. The suddenness can be expressed using the word "suddenly" before the subject:
I was walking down the street when suddenly I heard a loud bang behind me.
Or you can show the suddenness by using a verb that includes suddenness in its meaning, like "realize" in the example above.
Follow PhraseMix