Is there a difference between these two sentences?
As soon as I closed the front door I realised that my keys were inside.
No sooner had I closed the front door than I realised that my keys were inside.
The answer is no - they mean the same. They are both used to describe events that take place at the same time or very close together. But you will see that the grammar is different.
As soon as is followed here by the past simple tense.
No sooner is followed by the past perfect tense. The 'I had' becomes 'had I' - an example of an inversion - and the two parts of the sentence are linked by 'than'.
So it's: No sooner had I.......than......
Both are widely used, but 'No sooner' is seen more in written language.
Other options are:
The moment I closed the front door, I realised that my keys were inside. (the comma is used here to create a pause but it is not essential)
As I closed the front door, I realised that my keys were inside.
When closing the front door I realised that my keys were inside.
Note: While is not a good option here. While is used to describe actions that take place at the same time, but tends to be used when one of the actions is longer in time than the other:
While eating my lunch I realised that I had left my house keys at home.
Eating my lunch is the longer action, realised the shorter one.
Note here that left is in the past perfect tense because the actions - realised and left - are indicating different points in the past. They are not actions taking place at the same time. I left the keys before I realised.