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

Skip combination keypresses in player hotkeys #481

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/services/utility-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,17 +554,24 @@ export function playerHotKeys(event, player) {
let focusedWithinPlayer = activeElement.className.includes('vjs') || activeElement.className.includes('videojs');

let pressedKey = event.which;

// Check if ctrl/cmd/alt/shift keys are pressed when using key combinations
let isCombKeyPress = event.ctrlKey || event.metaKey || event.altKey || event.shiftKey;

/*
Trigger player hotkeys when focus is not on an input, textarea.
OR on a navigation tab with the key pressed is one of left/right arrow keys.
This specific combination of keys with a focused navigation tab is avoided to allow
keyboard navigation between tabbed UI components, instead of triggering player hotkeys.
Trigger player hotkeys when;
- focus is not on an input, textarea field on the page
- focus is on a navigation tab AND the key pressed is one of left/right arrow keys
this specific combination of keys with a focused navigation tab is avoided to allow
keyboard navigation between tabbed UI components, instead of triggering player hotkeys
- when key combinations are not in use with a key associated with hotkeys
*/
if (
activeElement &&
(inputs.indexOf(activeElement.tagName.toLowerCase()) !== -1 ||
(activeElement.role === "tab" && (pressedKey === 37 || pressedKey === 39))) &&
!focusedWithinPlayer
(activeElement &&
(inputs.indexOf(activeElement.tagName.toLowerCase()) !== -1 ||
(activeElement.role === "tab" && (pressedKey === 37 || pressedKey === 39))) &&
!focusedWithinPlayer)
|| isCombKeyPress
) {
return;
} else if (playerInst === null || playerInst === undefined) {
Expand Down