fix(player): Ctrl+0 causes a jump to the beginning of the video#1493
Merged
mihar-22 merged 1 commit intovidstack:mainfrom Feb 16, 2025
Merged
fix(player): Ctrl+0 causes a jump to the beginning of the video#1493mihar-22 merged 1 commit intovidstack:mainfrom
mihar-22 merged 1 commit intovidstack:mainfrom
Conversation
|
Does this fix the other keyboard shortcut issues where using the number pad or numbers navigates the video? I can't seem to find a way to disable these shortcuts. |
Contributor
Author
|
This fix disables Ctrl+number shortcuts only. Number-based navigation (without modifier keys) is not affected. I think number-based navigation is a feature, not a bug: for instance, this is how YouTube player works. |
|
Do you know if there is a way to disable seeking using the numbers? |
Contributor
Author
|
Probably this would work: diff --git a/packages/vidstack/src/core/keyboard/controller.ts b/packages/vidstack/src/core/keyboard/controller.ts
index bea1a0c3..984789d6 100644
--- a/packages/vidstack/src/core/keyboard/controller.ts
+++ b/packages/vidstack/src/core/keyboard/controller.ts
@@ -142,6 +142,7 @@ export class MediaKeyboardController extends MediaPlayerController {
}
if (!method && isNumberPress) {
+ return;
event.preventDefault();
event.stopPropagation();
this.#media.remote.seek((this.$state.duration() / 10) * Number(event.key), event);I'm not aware of simpler way to do that. |
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.
Closes #1462
Feel free to make any changes, thanks.