Skip to content

fix(video): prevent space bar from pausing video in fullscreen#1278

Merged
adamshiervani merged 1 commit into
jetkvm:devfrom
agh:fix/space-pauses-video
Mar 16, 2026
Merged

fix(video): prevent space bar from pausing video in fullscreen#1278
adamshiervani merged 1 commit into
jetkvm:devfrom
agh:fix/space-pauses-video

Conversation

@agh
Copy link
Copy Markdown
Contributor

@agh agh commented Mar 15, 2026

Fixes #265

Problem

Pressing Space in fullscreen mode pauses the video stream. Reported across Chrome, Edge, and Safari. The stream resumes on the next Space press but this makes fullscreen unusable for typing.

Root cause

Browsers treat <video> elements specially — Space toggles play/pause as a built-in behavior at the element level. The existing keyDownHandler on document calls preventDefault(), but DOM event propagation runs element → parent → ... → document. The video element processes the Space keydown and pauses playback before the document-level handler ever fires.

The existing workaround (videoKeyUpHandler at line 390) attaches a keyup listener on the video element that detects the pause and calls .play() to undo it, but:

  1. There is a visible pause/unpause flicker on every Space press
  2. It does not work in Safari (noted in the original code comment)

Fix

Add a keydown listener directly on the <video> element that calls preventDefault() for Space. This intercepts the event at the element level before the browser's native toggle runs, so the pause never occurs.

The existing keyup force-play handler is retained as a safety net for any browser that still manages to pause the stream.

Browsers treat <video> elements specially: Space toggles play/pause at
the element level as a built-in behavior. The existing keyDownHandler on
document calls preventDefault, but DOM event propagation runs element ->
parent -> document, so the video element processes the Space keydown and
pauses playback before the document-level handler ever fires.

The existing workaround attaches a keyup listener on the video element
that calls .play() to undo the pause, but this produces a visible
pause/unpause flicker on every space press and does not work in Safari.

Fix: add a keydown listener directly on the <video> element that calls
preventDefault for Space. This intercepts the event at the element level
before the browser's native toggle runs, so the pause never occurs. The
existing keyup force-play handler is retained as a safety net for any
browser that still manages to pause the stream.

Fixes jetkvm#265
@adamshiervani adamshiervani merged commit 0f55f1c into jetkvm:dev Mar 16, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pressing the space bar in full screen mode pauses the video.

2 participants