You can key the shared door to accept both unit keys, while each unit key will only be able to open their own unit and the shared door, but not the other unit.
I did this when I rented in a multi family home that had a shared outer door but individual unit front doors, so I could use my own apartment key to also open the outer shared door and the shared exterior basement door.