0

When I add pointer-events:none; to video (just to temporarily disable controls), if focus is on play button, spacebar still triggers play.

  1. is this intended behavior?

  2. what would be the cleanest to prevent this? (possible without javascript?)

To replicate, on page load, click play video to get focus, wait few seconds for pointer-events then use spacebar.

setTimeout(function(){ document.getElementById('video').classList.add('disabled') },4000)
.disabled{ pointer-events:none; }
<video controls id="video"> <source src="http://media.w3.org/2010/05/sintel/trailer.mp4"> </video>

3
  • What system are you running on because I cannot reproduce this (using Windows11 Edge, tried both in an SO snippet and as raw code)? Commented Aug 18, 2024 at 14:36
  • @AHaworth You need to press on the play button on the video, and then press the spacebar right after that. Me here on Windows11 Edge, too. Commented Aug 18, 2024 at 15:48
  • @AHaworth Windows 10, Chrome Commented Aug 19, 2024 at 8:36

1 Answer 1

1

What comes to my mind is also removing controls when disabling the video:

document.getElementById("video").attributes.removeNamedItem("controls"); 
Sign up to request clarification or add additional context in comments.

1 Comment

In the end I decided to remove focus: document.activeElement.blur();

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.