hardly, scarcely and no sooner
These three expressions can be used (often with a past perfect tense, (see here) to suggest that one thing happened very soon after another. Note the sentence structure:
Grammar
… hardly … when/before …
Grammar
… scarcely … when/before …
Grammar
… no sooner … than …
- I had hardly/scarcely closed my eyes when the phone rang.
- She was hardly/scarcely inside the house before the kids started screaming.
- I had no sooner closed the door than somebody knocked.
- We no sooner sat down in the train than I felt sick.
In a formal or literary style, inverted word order is possible (see here).
- Hardly had I closed my eyes when I began to imagine fantastic shapes.
- No sooner had she agreed to marry him than she started to have doubts.