mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 10:58:20 -07:00
Disable keyboard navigation for non-TV
This commit is contained in:
parent
8d02d05441
commit
17f9480188
@ -36,6 +36,11 @@ define(["inputManager", "layoutManager"], function (inputManager, layoutManager)
|
|||||||
10252: "MediaPlayPause"
|
10252: "MediaPlayPause"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keys used for keyboard navigation.
|
||||||
|
*/
|
||||||
|
var NavigationKeys = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
|
||||||
|
|
||||||
var hasFieldKey = false;
|
var hasFieldKey = false;
|
||||||
try {
|
try {
|
||||||
hasFieldKey = "key" in new KeyboardEvent("keydown");
|
hasFieldKey = "key" in new KeyboardEvent("keydown");
|
||||||
@ -60,11 +65,28 @@ define(["inputManager", "layoutManager"], function (inputManager, layoutManager)
|
|||||||
return KeyNames[event.keyCode] || event.key;
|
return KeyNames[event.keyCode] || event.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns _true_ if key is used for navigation.
|
||||||
|
*
|
||||||
|
* @param {string} key name
|
||||||
|
* @return {boolean} _true_ if key is used for navigation
|
||||||
|
*/
|
||||||
|
function isNavigationKey(key) {
|
||||||
|
return NavigationKeys.indexOf(key) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
function enable() {
|
function enable() {
|
||||||
document.addEventListener("keydown", function (e) {
|
document.addEventListener("keydown", function (e) {
|
||||||
|
var key = getKeyName(e);
|
||||||
|
|
||||||
|
// Ignore navigation keys for non-TV
|
||||||
|
if (!layoutManager.tv && isNavigationKey(key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var capture = true;
|
var capture = true;
|
||||||
|
|
||||||
switch (getKeyName(e)) {
|
switch (key) {
|
||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
inputManager.handle("left");
|
inputManager.handle("left");
|
||||||
break;
|
break;
|
||||||
@ -128,6 +150,7 @@ define(["inputManager", "layoutManager"], function (inputManager, layoutManager)
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
enable: enable,
|
enable: enable,
|
||||||
getKeyName: getKeyName
|
getKeyName: getKeyName,
|
||||||
|
isNavigationKey: isNavigationKey
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -1087,11 +1087,6 @@ define(["playbackManager", "dom", "inputManager", "datetime", "itemHelper", "med
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Keys used for keyboard navigation.
|
|
||||||
*/
|
|
||||||
var NavigationKeys = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clicked element.
|
* Clicked element.
|
||||||
* To skip 'click' handling on Firefox/Edge.
|
* To skip 'click' handling on Firefox/Edge.
|
||||||
@ -1109,7 +1104,7 @@ define(["playbackManager", "dom", "inputManager", "datetime", "itemHelper", "med
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layoutManager.tv && NavigationKeys.indexOf(key) != -1) {
|
if (layoutManager.tv && keyboardnavigation.isNavigationKey(key)) {
|
||||||
showOsd();
|
showOsd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user