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 41336a8 commit bc90940
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 @@ -115,7 +115,7 @@ export class MediaKeyboardController extends MediaPlayerController {
}

#onKeyDown(event: KeyboardEvent) {
if (!event.key || MODIFIER_KEYS.has(event.key)) return;
if (!event.key || modifierKeyPressed(event)) return;

const focusedEl = document.activeElement;

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 bc90940

Please sign in to comment.