keyboard D key is down >> simulate platform pressing right
on d pressed >> player set animation "walk"[looping]
on mouse click >> player set animation "attack"[not looping]
player on animation "attack" finished >> player set animation "walk"
if you want the player to stop moving when the attack substitute:
keyboard D key is down >> simulate platform pressing right
with:
keyboard D key is down, and animation "walk" is playing[or animation "attack" is not playing] >> simulate platform pressing right