Grammar
N2AI-drafted〜たとたん(に)
the moment (one did), just as
Formation
V-た形 + とたん(に)
Usage
Describes something that happened suddenly and unexpectedly right at the instant the first action was completed. The second clause must be a past, already-realized event, so intentions, requests and volitional statements cannot follow it. Because of the nuance of surprise, it is not used for things you planned to do yourself right afterwards; for that use 〜たらすぐに.
Examples
窓を開けたとたん、冷たい風が入ってきた。
まどをあけたとたん、つめたいかぜがはいってきた。
The moment I opened the window, cold wind came in.
家に着いたとたんに、雨が降り出した。
いえについたとたんに、あめがふりだした。
Just as I got home, it started to rain.
彼は立ち上がったとたん、めまいがして倒れてしまった。
かれはたちあがったとたん、めまいがしてたおれてしまった。
The instant he stood up, he felt dizzy and collapsed.