Skip to content

Commit

Permalink
Use modern syntax & slight perf improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
gnattu committed May 21, 2024
1 parent 68bac17 commit 0271ae4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/scripts/keyboardNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function isNavigationKey(key) {
* @return {boolean} _true_ if key is used for media playback control.
*/
export function isMediaKey(key) {
return MediaKeys.indexOf(key) != -1;
return MediaKeys.includes(key);
}

/**
Expand All @@ -123,6 +123,7 @@ export function isInteractiveElement(element) {
}

export function enable() {
const hasMediaSession = 'mediaSession' in navigator;
window.addEventListener('keydown', function (e) {
const key = getKeyName(e);

Expand All @@ -132,7 +133,7 @@ export function enable() {
}

// Ignore Media Keys for non-TV platform having MediaSession API
if (!layoutManager.tv && isMediaKey(key) && 'mediaSession' in navigator) {
if (!layoutManager.tv && isMediaKey(key) && hasMediaSession) {
return;
}

Expand Down

0 comments on commit 0271ae4

Please sign in to comment.