So, make it three codes: the pilots' code, the cabin crew's, and a duress code. Punch in the duress code, and the other codes stop working, and the transponder automatically squawks the hijack code.
Maybe the tradeoffs chosen in response to 9/11 are now inappropriate. Maybe suicidal pilots are now the greater threat. Other than the occasional nutcase, easily subdued by passengers and crew, have there been any serious attempts to take over a cockpit since then?
If more of these incidents occur, they will have air marshals on every plane with codes to override pilot attempts to lock themselves in.
You don't even need to change the coding on the door lock. Just follow the same rule that all U.S. airlines follow: there must be at least two people in the cockpit at all times. If one of the pilots must leave to use the restroom (or for any other reason), then a flight attendant or some other airline employee (often a deadheading pilot) steps into the cockpit until the pilot returns.