Hello and welcome to JustAnswer!
You may have one problem or a couple things going on.
First take a look at the latch and see if the pawl has rotated into the closed position somehow. The pawl is the piece in the latch that turns to capture the striker. If you're unsure then you can compare it to another door.
If it has rotated to the closed position then insert a screwdriver in it, pull the handle while prying the pawl and it should release.
It seems more likely that you have a failed latch. If it wouldn't unlock even with the key then there is a mechanical problem in the latch anyway, it may now be stuck in the open position and the pawl won't rotate to close around the striker. If you find the pawl in the normal position yet the door won't stay closed and the handle is returning correctly then you have a bad latch.