write + (past) + the moment
kaita totan ni
the moment; no sooner had — an abrupt, usually surprising, consequence
meaning: the moment you write
この財布、開けたとたんに小銭が全部落ちるんだよね。
kono saifu, aketa totan ni kozeni ga zenbu ochiru n da yo ne.
This wallet — the moment you open it, all the change falls out, you know. casual
電気を消したとたんに、電話が鳴った。
denki o keshita totan ni, denwa ga natta.
The moment I turned off the light, the phone rang. neutral