If you press the switch to the right of the door, you'll see that the key temporarily appears. All you have to do is find a way up to the key, and you should be able to get it without any problem.
There's a catapult next to the gate that will help you.