You could add a variable to the player and when left key is pressed set it to L and when right key is pressed set it to R. When the player stops moving, if L then set left idle, and if R then set right idle.
I assume the animations are different for left and right? If not, the usual thing is to set the player mirrored or not mirrored on left/right key press so they would already be facing the correct way.