[clause]とき、…とき — when
ConditionClause + とき sets the time: “when …”. The verb tense before とき matters.
日本へ 行くとき、カメラを 買いました。
にほんへ いくとき、カメラを かいました。
When I went to Japan, I bought a camera (before going).
とき = “at the time when”. The form before とき shows timing: 行くとき (dictionary form) = before/while going; 行ったとき (た-form) = after having arrived. Nouns and adjectives connect with の/な/い as usual.