javascript - spacebar not cancelling default event on firefox -


i'm building video player , 1 of features related toggle play when hit spacebar , execute process within. works on browsers except firefox. if hit spacebar , video paused, plays less second , gets paused. there i'm not aware of causing behavior related firefox?

player.addeventlistener('keydown', function(e) {     if (e.keycode === 32) {       if (player.paused) {          player.play();       } else {          player.pause();       }       // ... other actions event       e.preventdefault();      e.stoppropagation();    } }, false); 

firefox triggers click event when using space bar. using conditional avoid firefox when pressing space bar fixes it


Comments

Popular posts from this blog

How to use SUM() in MySQL for calculated values -

loops - Spock: How to use test data with @Stepwise -