When click key, corresponds button on screen should place a highlight effect, and the corresponds radio should be played.
keyCode
is deprecated now, so changed tokey
.- hover effect on button.
- User can click the button on screen to trigger the effect change and sound.
- add listener to listen to
keydown
event onwindow
. - get
key
value, usequerySelector
to find correspond button (div) and radio. - trigger the highlight effect by add class, call
play()
to play radio, you also have to set radio start point first. - remove the highlight effect after the animation finished. (listent to
transitionend
event). - listen to
click
event on button, you should be carful of the different betweene.target
ande.eventTarget
.