diff --git a/manual_trading_hub/static/chart.js b/manual_trading_hub/static/chart.js index 640fea2..ef459fa 100644 --- a/manual_trading_hub/static/chart.js +++ b/manual_trading_hub/static/chart.js @@ -795,13 +795,28 @@ tfDigitTimer = setTimeout(commitTfDigitBuffer, TF_DIGIT_TIMEOUT_MS); } - function isChartFullscreenShortcut(e) { - if (e.altKey || e.metaKey) return false; - const isSpace = - e.code === "Space" || e.key === " " || e.key === "Spacebar"; - if (isSpace && e.ctrlKey) return true; - if ((e.key === "f" || e.key === "F") && !e.ctrlKey && !e.shiftKey) return true; - return false; + function isChartFullscreenKey(e) { + if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey) return false; + return e.code === "KeyF" || e.key === "f" || e.key === "F"; + } + + function onChartFullscreenKey(e) { + if (!isMarketPageActive() || !isChartFullscreenKey(e)) return; + if (isTypingInField(e.target)) return; + e.preventDefault(); + e.stopImmediatePropagation(); + toggleChartFullscreen(); + } + + function focusMarketChartArea() { + const wrap = elChartWrap; + if (!wrap) return; + if (!wrap.hasAttribute("tabindex")) wrap.setAttribute("tabindex", "-1"); + try { + wrap.focus({ preventScroll: true }); + } catch (err) { + /* ignore */ + } } function onMarketKeydown(e) { @@ -814,14 +829,6 @@ return; } - if (isChartFullscreenShortcut(e)) { - if (isTypingInField(e.target) && (e.key === "f" || e.key === "F")) return; - e.preventDefault(); - e.stopPropagation(); - toggleChartFullscreen(); - return; - } - if (!canUseTfKeyboard(e)) return; if (e.key >= "0" && e.key <= "9") { e.preventDefault(); @@ -1603,7 +1610,16 @@ updateIndicators(); }); }); + const pageMarket = document.getElementById("page-market"); + const fsKeyTargets = [window, pageMarket, elChartWrap, chartHost].filter(Boolean); + fsKeyTargets.forEach(function (el) { + el.addEventListener("keydown", onChartFullscreenKey, true); + }); window.addEventListener("keydown", onMarketKeydown, true); + if (elChartWrap) { + if (!elChartWrap.hasAttribute("tabindex")) elChartWrap.setAttribute("tabindex", "-1"); + elChartWrap.addEventListener("mousedown", focusMarketChartArea); + } if (elFsExchange) { elFsExchange.addEventListener("change", function () { syncMainFromFsToolbar(); @@ -1643,6 +1659,7 @@ } else { readQuery(); } + focusMarketChartArea(); startAutoRefresh(); await loadChart(false); startPriceTagTimer(); diff --git a/manual_trading_hub/static/index.html b/manual_trading_hub/static/index.html index fdbca84..3a7a5a1 100644 --- a/manual_trading_hub/static/index.html +++ b/manual_trading_hub/static/index.html @@ -60,7 +60,7 @@ - +
@@ -240,7 +240,7 @@
- +