Skip to content

Comments

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

Merged
mihar-22 merged 1 commit intovidstack:mainfrom
codonaft:fix-1462
Feb 16, 2025
Merged

fix(player): Ctrl+0 causes a jump to the beginning of the video#1493
mihar-22 merged 1 commit intovidstack:mainfrom
codonaft:fix-1462

Conversation

@alopatindev
Copy link
Contributor

@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
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.

@ndeshpande2022
Copy link

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

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

@mihar-22 mihar-22 merged commit 3391749 into vidstack:main Feb 16, 2025
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

3 participants