Why does keydown event default to the else if statement in javascript
14:54 28 Mar 2026

i have a keydown event listener that checks if the user presses "d" to go to the next song in the array and "a" to go back, but for some reason whenever i press any key it defaults to the "a" statement. i kind of fixed it by doing another check to see if the user actually pressed one of the two keys (commented out if statement), but i don't think it's the best way to fix this since i am basically checking twice for the key input

the event listener code is at the bottom


    
    audioplayer

    

        
javascript html if-statement dom-events