Early on in Claire's Story you will get the ability to switch to Moira (Y/Triangle). Stun a zombie with her flashlight and Claire will attack it automatically.
In the room where you shoot down the keys you will be attacked by a zombie which you can use to get this right away, but it can be done throughout the whole game.
This works the same in Co-op.