0

So I wanted to disable the arrow keys shortcuts for default browser video player. I figured it looks like it's using "keypress" event, so I should be able to do it with simple

player.addEventListener("keypress", (e) => {
            e.preventDefault();
            e.stopPropagation();
        });

however it didn't work, because as I found out the listener weren't firing when an arrow key was pressed, it does work for all other keys. I added a console.log instead of preventDefault inside listener func, and when smashing random keys on my keyboard I was getting the log as expected, but for arrow keys there was nothing.

With "keydown" event listeners fires, but preventDefault does nothing, arrow keys still work.

Why is that? And is there any way to disable those shortcuts and make "keypress" event listener for arrow keys work?

ncpa0cpl
  • 192
  • 1
  • 13

1 Answers1

0

After a few failed attempts I remembered that I too had the same problem and that I solved it thanks to a post by KayaNatsumi's on html5 video behavior control.

Link to question: https://stackoverflow.com/a/63040542/14124576

  • From what I see this completely disables seeking, which is not what I want to do, I want seeking to be possible. I want to disable keyboard shortcuts only – ncpa0cpl Aug 18 '20 at 13:04