Skip to content

Add volume control with right mouse button + scroll wheel - #4479

Open
workingwithkwan wants to merge 3 commits into
code-charity:masterfrom
workingwithkwan:claude/volume-right-click-wheel
Open

workingwithkwan wants to merge 3 commits into
code-charity:masterfrom
workingwithkwan:claude/volume-right-click-wheel

Conversation

@workingwithkwan

@workingwithkwan workingwithkwan commented Nov 15, 2026 •

Copy link
Copy Markdown

What this adds

The right mouse button can be part of a shortcut. Hold it while scrolling in the shortcut dialog and it is recorded together with the wheel, for any shortcut, e.g. Increase volume = right mouse button + wheel up, Decrease volume = right mouse button + wheel down.

Details

  • No context menu appears after such a shortcut. Windows opens the context menu when the button is released; Linux and macOS open it when the button is pressed. On those two, the player’s menu is held back while the button is down and shown on release if no shortcut was used.
  • Without a shortcut that uses the right mouse button, right-clicks are never touched.
  • In the shortcut dialog, the first scroll now replaces the shortcut that is shown instead of adding to it.

Second commit: volume text

The volume shown by the volume shortcuts and by this gesture is now a whole number ("55" instead of "55.00"), white on a 20% black background, centred horizontally and three quarters of the way up the player, and it fades out within one second. Other status texts (playback speed, filters) are unchanged. This is a matter of taste, so it is a separate commit that can be dropped.

Testing

  • Manually on YouTube in the latest Firefox on Windows.
  • 34 new unit tests in 'tests/unit/shortcuts-right-mouse-button.test.js'; the full suite passes.
  • In Chromium on Linux with the extension loaded and real mouse input, against a stand-in player page rather than live YouTube.
  • Not tried on live YouTube on Linux or macOS, so the held-back context menu there is covered only by the two points above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VnPaaESvf1EA3kfaCTrKV6

Hold the right mouse button over the player and use the scroll wheel to
change the volume. New switch under Shortcuts > Volume, off by default.
The amount per wheel notch is the existing "Step" slider
(shortcuts_volume_step), shared with the volume shortcuts.

- The page does not scroll during the gesture and no context menu
  appears afterwards.
- Windows fires 'contextmenu' after 'mouseup'; Linux and macOS fire it
  right after 'mousedown'. There the player's menu is held back while
  the button is down and replayed on release if the wheel was not used.
- A wheel-only shortcut does not fire on top of the gesture.
- The setting applies to open tabs without a reload.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VnPaaESvf1EA3kfaCTrKV6
The volume shown when it is changed by the volume shortcuts or by right
mouse button + scroll wheel is now a whole number ("55" instead of
"55.00"), 30px, white on a black background of 20% opacity, horizontally
centered and 3/4 of the way up the player. It fades out within one
second and each new change restarts the fade.

showStatus() takes an optional type and duration for this; every other
status text keeps its format, position, colour, size and 500 ms.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VnPaaESvf1EA3kfaCTrKV6
@ImprovedTube2

Copy link
Copy Markdown
Member

hi! and thank you @workingwithkwan
can it be more integrated? did you notice you can also set such shortcut with our interface (mix of keyboard and mouse)

Replaces the separate "Hold right mouse button + scroll wheel" switch.
The right mouse button is now part of the normal shortcuts: hold it
while scrolling in the shortcut dialog and it is recorded together with
the wheel (and with Alt / Ctrl / Shift or keys pressed before), for any
shortcut, e.g. Increase volume = right mouse button + wheel up.

- Menu (satus.js): the wheel recorder stores `context` when the right
  mouse button is held, shows it before the wheel, and suppresses the
  context menu while the dialog is open.
- Menu (satus.js): the first scroll after opening the dialog replaces
  the shortcut that is shown instead of adding to it. Before, scrolling
  on "Increase volume" recorded "arrow up + wheel".
- Page (shortcuts.js): `context` is matched like Alt / Ctrl / Shift, so
  "wheel" and "right mouse button + wheel" are different shortcuts.
- The context-menu handling from the first commit moves into the
  shortcut listeners and only acts when a shortcut uses the right mouse
  button; without one, right-clicks are never touched.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VnPaaESvf1EA3kfaCTrKV6
@workingwithkwan

Copy link
Copy Markdown
Author

@ImprovedTube2 Good point, thanks. I’ve reworked it: the separate switch is gone, and the right mouse button can now be recorded in the normal shortcut dialog. Hold it while scrolling and it is stored together with the wheel (also with Ctrl / Alt / Shift or keys), for any shortcut, e.g. Increase volume = right mouse button + wheel up. I also changed the dialog so that the first scroll replaces the shortcut that is shown instead of adding to it; scrolling on “Increase volume” used to record “arrow up + wheel”. The context-menu handling only acts when a shortcut uses the right mouse button. It’s the third commit.

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.

3 participants