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

Fixed event key with space #2581

Merged
merged 2 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/js/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ const controls = {
'keydown keyup',
(event) => {
// We only care about space and ⬆️ ⬇️️ ➡️
if (!['Space', 'ArrowUp', 'ArrowDown', 'ArrowRight'].includes(event.key)) {
if (![' ', 'ArrowUp', 'ArrowDown', 'ArrowRight'].includes(event.key)) {
return;
}

Expand All @@ -420,12 +420,12 @@ const controls = {
const isRadioButton = matches(menuItem, '[role="menuitemradio"]');

// Show the respective menu
if (!isRadioButton && ['Space', 'ArrowRight'].includes(event.key)) {
if (!isRadioButton && [' ', 'ArrowRight'].includes(event.key)) {
controls.showMenuPanel.call(this, type, true);
} else {
let target;

if (event.key !== 'Space') {
if (event.key !== ' ') {
if (event.key === 'ArrowDown' || (isRadioButton && event.key === 'ArrowRight')) {
target = menuItem.nextElementSibling;

Expand Down Expand Up @@ -504,7 +504,7 @@ const controls = {
menuItem,
'click keyup',
(event) => {
if (is.keyboardEvent(event) && event.key !== 'Space') {
if (is.keyboardEvent(event) && event.key !== ' ') {
return;
}

Expand Down
8 changes: 4 additions & 4 deletions src/js/listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ class Listeners {
return;
}

if (event.key === 'Space' && matches(focused, 'button, [role^="menuitem"]')) {
if (event.key === ' ' && matches(focused, 'button, [role^="menuitem"]')) {
return;
}
}

// Which keys should we prevent default
const preventDefault = [
'Space',
' ',
'ArrowLeft',
'ArrowUp',
'ArrowRight',
Expand Down Expand Up @@ -118,7 +118,7 @@ class Listeners {
}
break;

case 'Space':
case ' ':
case 'k':
if (!repeat) {
silencePromise(player.togglePlay());
Expand Down Expand Up @@ -663,7 +663,7 @@ class Listeners {
elements.buttons.settings,
'keyup',
(event) => {
if (!['Space', 'Enter'].includes(event.key)) {
if (![' ', 'Enter'].includes(event.key)) {
return;
}

Expand Down