Hi, Wael Shaltoot,
Grammatically speaking, you can use both "to open" and "for opening." Now, the sentence does not make much sense. Keys are used for closing and opening doors.
Perhaps what the author of that sentence meant to say is that keys are not needed when doors are already open: Keys are not used for open doors.