たとたん means "the moment": right after one thing happened, something else happened, usually something sudden or unexpected. It follows the た-form of a verb, and に after it is optional. In kanji it is とたん途端.
The verb before とたん is always the た-form, never the dictionary form: ×開けるとたん. The second half reports something that actually happened, so it is nearly always in the past too.
The second half is something that happened to you or around you, outside your control: the weather, a feeling, a sudden realisation. Your own deliberate next step, a request or a plan doesn't fit; for those, use たらすぐ.
Someone else's sudden reaction is fine, because from where the speaker stands it is unexpected.