We use the word とき to describe when something happens or happened.
sentence A とき, sentence B
When A, B
Sentence A always ends in short form, either in the past or present tense.
If (at the time the main event B takes place) A is current or is still in "in the future", use the present tense in A.
If (at the time of main event B) A is already "in the past" use the past tense in A