〜るとき・〜たとき
when (before it happens vs. after it has happened)
Dictionary form + とき (not yet) · た-form + とき (already)
Sign up free to review this point on a spaced schedule.
With とき, the verb's tense shows the order of events, not when the whole sentence happens.
日本へ行くとき、カメラを買った: "when I was about to go to Japan, I bought a camera", so you bought it before leaving. 日本へ行ったとき、カメラを買った: "when I went to Japan, I bought a camera", so you bought it there.
The rule: use the dictionary form if the とき action hasn't happened yet when the main action takes place, and the た-form if it already has.
Everyday greetings show it clearly: 家を出るとき「いってきます」 (before you're out of the door), 帰ったとき「ただいま」 (once you're home). This is a favourite trick in grammar questions.
Examples
日本へ行くとき、空港でカメラを買った。
Before leaving for Japan, I bought a camera at the airport.
日本へ行ったとき、京都でお茶を飲んだ。
When I went to Japan, I had tea in Kyoto.
家を出るとき、「いってきます」と言います。
When you leave the house, you say "ittekimasu".
家に帰ったとき、「ただいま」と言います。
When you get home, you say "tadaima".
朝起きたとき、雨が降っていた。
When I woke up this morning, it was raining.
夜寝るとき、電気を消します。
I turn off the light when I go to bed.