How to stop animation at the end regarding of input

Hello. I have a simple build that allows me to play an animation using a certain key, then play it backwards using another key. The problem comes when I hold long enough the key and the animation finishes by pressing again the same key the animation will start over again.

Is there any way to avoid this? I need to play the animation and no matter how times the input keys have pressed the animation to hold on to the last frame or first frame (depends on the moving direction - forward or backwards) That way it would be “one-time” animation instead of looping the animation over again. Here is the BP until now -

Thanks!

Update:

Okay guys, I almost do this. But for some reason, I still cannot make it for the backwards part. I made it when we get to the finished animation using OnFinished function to set the play rate to 0. But for some reason that is not working for the “Play Reverse” animation. When I get to the backwards animation end it still going to count the frames and If I hold the button long enough it goes to -5000 frames for example and does not stop on 0.

This is my solution until now: