Rearrange keydown event handling

This commit is contained in:
Dmitry Lyzo 2020-06-28 23:46:27 +03:00
parent 39b412bb06
commit 62a2f4b17d
3 changed files with 16 additions and 4 deletions

View File

@ -65,6 +65,9 @@ define(['playbackManager', 'layoutManager', 'text!./subtitlesync.template.html',
event.preventDefault();
}
}
// FIXME: TV layout will require special handling for navigation keys. But now field is not focusable
event.stopPropagation();
});
subtitleSyncTextField.blur = function() {

View File

@ -1080,7 +1080,7 @@ define(['playbackManager', 'dom', 'inputManager', 'datetime', 'itemHelper', 'med
*/
var clickedElement;
function onWindowKeyDown(e) {
function onKeyDown(e) {
clickedElement = e.srcElement;
var key = keyboardnavigation.getKeyName(e);
@ -1194,6 +1194,13 @@ define(['playbackManager', 'dom', 'inputManager', 'datetime', 'itemHelper', 'med
}
}
function onKeyDownCapture() {
// Restart hide timer if OSD is currently visible
if (currentVisibleMenu) {
showOsd();
}
}
function onWindowMouseDown(e) {
clickedElement = e.srcElement;
}
@ -1330,7 +1337,8 @@ define(['playbackManager', 'dom', 'inputManager', 'datetime', 'itemHelper', 'med
});
showOsd();
inputManager.on(window, onInputCommand);
dom.addEventListener(window, 'keydown', onWindowKeyDown, {
document.addEventListener('keydown', onKeyDown);
dom.addEventListener(document, 'keydown', onKeyDownCapture, {
capture: true
});
dom.addEventListener(window, window.PointerEvent ? 'pointerdown' : 'mousedown', onWindowMouseDown, {
@ -1350,7 +1358,8 @@ define(['playbackManager', 'dom', 'inputManager', 'datetime', 'itemHelper', 'med
statsOverlay.enabled(false);
}
dom.removeEventListener(window, 'keydown', onWindowKeyDown, {
document.removeEventListener('keydown', onKeyDown);
dom.removeEventListener(document, 'keydown', onKeyDownCapture, {
capture: true
});
dom.removeEventListener(window, window.PointerEvent ? 'pointerdown' : 'mousedown', onWindowMouseDown, {

View File

@ -78,7 +78,7 @@ export function isNavigationKey(key) {
}
export function enable() {
document.addEventListener('keydown', function (e) {
window.addEventListener('keydown', function (e) {
const key = getKeyName(e);
// Ignore navigation keys for non-TV