HTML5 video speed control — beyond 2x, with keyboard shortcuts
The built-in video player gives you up to 2x speed and that is it. Sometimes you want a lecture at 2.75x, or a webcam recording at 0.5x. One JustZix rule adds keyboard speed control to every HTML5 player — YouTube, Vimeo, online courses, anything.
Why 2x is not the limit
The <video> element has a playbackRate property and it has no upper bound on the HTML side — it is the player's UI that artificially caps the slider at 2x. By setting playbackRate from code, you bypass that slider entirely.
The rule
URL pattern: a video site (e.g. *://*.youtube.com/*) or * globally. The rule's JavaScript:
document.addEventListener('keydown', (e) => {
if (/input|textarea/i.test(e.target.tagName)) return;
const v = document.querySelector('video');
if (!v) return;
if (e.key === 'd') v.playbackRate += 0.25;
if (e.key === 's') v.playbackRate = Math.max(0.25, v.playbackRate - 0.25);
if (e.key === 'r') v.playbackRate = 1;
});
Keys: D speeds up by 0.25x, S slows down, R resets to 1x.
How it works
- The input/textarea guard. The first line drops events while you are typing in a text field — without it, a "d" in a comment would change the speed.
- querySelector('video'). We take the first video element. On pages with a single player that is enough.
- The 0.25x step. Small, so you can land precisely on a comfortable pace.
Extensions — seek and Picture-in-Picture
It is easy to add arrow-key seeking and picture-in-picture:
if (e.key === 'ArrowRight') v.currentTime += 10;
if (e.key === 'ArrowLeft') v.currentTime -= 10;
if (e.key === 'p') {
document.pictureInPictureElement
? document.exitPictureInPicture()
: v.requestPictureInPicture();
}
A slider variant — the SLIDER action
Prefer a slider to keys? Make a SLIDER action in the JustZix action bar — you drag it, and the action code sets document.querySelector('video').playbackRate to the slider value. Speed under your thumb, no keys to memorize.
Pitfalls
- Very high speed drops the sound. Above about 4x the browser often mutes audio — that is an engine limit, not a rule bug.
- SPAs and changing video. On YouTube the next video is the same
<video>element —querySelectorinside the handler reads the current state, so it works after moving to the next clip. - Ads are video too. Sometimes
querySelector('video')hits the ad player. Once the ad ends you are back on the real one.
See also
- Examples — the video snippet and other ready-made code
- YouTube power-user — more YouTube rules
- The SLIDER action — a slider as a control
Install JustZix — and watch at your pace, not the player's.
Rate this post
No ratings yet — be the first.