Skip to content

Commit

Permalink
fix(player): Ctrl+0 causes a jump to the beginning of the video
Browse files Browse the repository at this point in the history
  • Loading branch information
alopatindev committed Nov 1, 2024
1 parent 190f638 commit 626f835
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/vidstack/src/core/keyboard/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class MediaKeyboardController extends MediaPlayerController {
return;
}

if (!method && isNumberPress) {
if (!method && isNumberPress && !modifierKeyPressed(event)) {
event.preventDefault();
event.stopPropagation();
this.#media.remote.seek((this.$state.duration() / 10) * Number(event.key), event);
Expand Down Expand Up @@ -288,3 +288,12 @@ const SYMBOL_KEY_MAP = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')'];
function replaceSymbolKeys(key: string) {
return key.replace(/Shift\+(\d)/g, (_, num) => SYMBOL_KEY_MAP[num - 1]);
}

function modifierKeyPressed(event: KeyboardEvent) {
for (const key of MODIFIER_KEYS) {
if (event[key.toLowerCase() + 'Key']) {
return true;
}
}
return false;
}

0 comments on commit 626f835

Please sign in to comment.