Verb[た]
[i-adj]
[na-adj] + な
Noun + の
The word とき means "when" or "at the time of" and is used to describe the time or occasion when something happens. It connects two clauses, where the first clause sets the time context for the second.
An important nuance of とき is the difference between using the dictionary form and the た-form of a verb before it. This changes the timing relationship between the two clauses.
Verb[dictionary form] + とき → The action in the main clause happens before the verb before とき is completed.
Verb[た-form] + とき → The action in the main clause happens after the verb before とき is completed.
In the first sentence, the camera was bought before arriving in Japan (e.g., at the airport). In the second, it was bought after arriving in Japan.
The particle に can optionally be added after とき to emphasize the specific point in time. Both とき and ときに are natural, but ときに sounds slightly more precise.
The tense of the overall sentence is determined by the main clause (the part after とき), not by the clause before とき. Even when talking about the past, the clause before とき can use the dictionary form.