Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(player): Ctrl+0 causes a jump to the beginning of the video #1493

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alopatindev
Copy link

@alopatindev alopatindev commented Nov 1, 2024

Closes #1462

Feel free to make any changes, thanks.

@alopatindev alopatindev changed the title fix(player): Ctrl+0 causes a jump to the beginning of the video Draft: fix(player): Ctrl+0 causes a jump to the beginning of the video Nov 1, 2024
@alopatindev alopatindev changed the title Draft: fix(player): Ctrl+0 causes a jump to the beginning of the video fix(player): Ctrl+0 causes a jump to the beginning of the video Nov 1, 2024
@ndeshpande2022
Copy link

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.

@alopatindev
Copy link
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.

@ndeshpande2022
Copy link

Do you know if there is a way to disable seeking using the numbers?

@alopatindev
Copy link
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.

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.

Ctrl+0 causes a jump to the beginning of the video
2 participants