たとたんに, frequently seen using its kanji form
た途端(とたん)に is a structure used to convey that something happens 'the instant', or 'the moment' that something else occurs. It is a combination of the
auxiliary verb た (indicating the completion of a verb), and the
noun 途端(とたん) 'on the tip of' used adverbially (with
に).
(A)
た途端(とたん)に (B) is used to express (B) things that are beyond the control of the speaker, and may be considered strange, or unexpected.
高速(こうそく)に乗(の)った途端(とたん)に、タイヤがパンクした。
The moment I got on the highway, my tire got punctured.
布団(ふとん)に入(はい)った途端(とたん)に先輩(せんぱい)から電話(でんわ)がかかってきた。
The moment I got into my futon, I received a call from my senpai.
As 途端(とたん) literally means 'on the tip of', any (B) action is considered to happen either directly upon (A), or even simultaneously with (A).