With regards to the key hole: Perhaps this is to allow the door to be locked when noone is on board the aircraft. this would stop anyone boarding an unatended ac at a gate and accessing the cockpit. Once the pilots are in the cockpit I would imagine there would be a second lock that can only be accessed from inside the cockpit.
With regards to the FA
entering the cockpit, it could be for any of the following reasons:
1) To open the door to allow the pilot back in
2) To monitor the remaining member of staff incase he has a heart attack. They can then open the door and alert the other member of flight crew
3) To provide an extra body in the event a terrorist tries to gain access when the pilot is in the loo...
Well theres a few reasons, im sure there are many more!