She took off her hat when she entered the room.

Literal

She [topic-は] room [toward-へ] enter when hat [object-を] removed.

帽子を取る ('to take off a hat,' literally 'to remove') — Japanese uses 取る for hat removal. とき marks the temporal occasion.