fix: Workaround for video.js button focus issue with Space/Enter hotkeys #1724
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
When watching a VOD and clicking on any control bar button (e.g., fullscreen), the button remains focused. Pressing Space to pause the video instead triggers a click on the focused button, causing unintended behavior (e.g., exiting fullscreen instead of pausing).
This is a known video.js bug: videojs/video.js#2669
Description
This PR implements a workaround for the video.js button focus issue. A document-level keydown event listener using the capture phase intercepts Space key presses before they reach the button's native handlers. When Space is pressed while a control bar button (.vjs-control-bar) is focused, the button is blurred via blur(), allowing the hotkey handler to process the key event normally.
Steps for Testing
2.Navigate to a VOD stream
3.Click on the fullscreen button in the video player control bar
4.Observe the fullscreen button has a visible focus ring
5.Press the Space key
6.✅ Video should pause/play instead of toggling fullscreen