I have a flashing sprite css animation for an empty div.
#flashIt{
width: 50%;
height: 100px;
background: blue;
margin: 10px auto;
border: solid 2px black;
left: 25%;
animation: flash 1s linear infinite;
}
@keyframes flash {
0% { opacity: 1; }
50% { opacity: .1 }
100% { opacity: 1; }
}
So this animation works as it is. However I want the animation to begin when a key is pressed by the user on their keyboard. How can I do this using JS? Help on this would be much appreciated. Thanks