Repository navigation
Add opt-in scoped hotkeys - #1377
Open
captbaritone wants to merge 3 commits into
Open
captbaritone wants to merge 3 commits into
captbaritone wants to merge 3 commits into
Conversation
✅ Deploy Preview for tourmaline-kringle-c98715 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Size Change: +29 B (+0.01%) Total Size: 490 kB 📦 View Changed
|
captbaritone
force-pushed
the
scoped-hotkeys
branch
3 times, most recently
from
October 15, 2026 17:00
05cfd28 to
948a764
Compare
enableHotkeys now also accepts "scoped", which only handles hotkeys while focus is within Webamp. This lets embedders with their own keyboard interactions enable hotkeys without Webamp intercepting keys page-wide. Scoped hotkeys attach the existing hotkey listener to Webamp's root DOM node instead of the document. enableHotkeys: true behaves exactly as before.
Rather than binding global hotkeys in the constructor and scoped hotkeys in <App>, bind both in <App>, choosing the document or Webamp's DOM node as the target. Hotkeys are unbound when the React root unmounts (on dispose()). This means enableHotkeys: true now takes effect once Webamp renders rather than when it is constructed.
captbaritone
force-pushed
the
scoped-hotkeys
branch
from
October 15, 2026 17:20
948a764 to
e69098c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
enableHotkeys: trueinstalls a document-levelkeydownlistener. On a page with its own keyboard interactions, that means Webamp intercepts keys like X, C, V and the arrow keys everywhere, so an embedder in that situation can't turn hotkeys on.This adds a scoped mode:
true"scoped"false/ omittedImplementation
bindHotkeys(dispatch, target = document)takes an optional element to listen on.Appnow binds hotkeys for both modes. It listens ondocumentfortrueand on Webamp's root DOM node (#webamp) for"scoped". Keys pressed inside Webamp bubble to the root node, and keys pressed elsewhere never reach it.dispose()triggers.Behavior change for
enableHotkeys: true: hotkeys now start working once Webamp renders, instead of as soon as it's constructed. Previously they also worked while the skin was loading, and on instances that were never rendered.API shape: I extended
enableHotkeystoboolean | "scoped"rather than adding a separate option such ashotkeys: "scoped" | "global" | false. That keeps it backward compatible and avoids two options that overlap. Happy to switch if you'd prefer a new option.Docs are updated in the constructor options and hotkeys pages.
Testing
hotkeys.test.tscovers:tsc,eslint,prettier --checkandvitest runpass locally.