diff options
| author | Tyler <tyler@tylerhoang.xyz> | 2026-05-17 01:03:55 -0700 |
|---|---|---|
| committer | Tyler <tyler@tylerhoang.xyz> | 2026-05-17 01:03:55 -0700 |
| commit | c3268bc66c141dcaa647c674bad288586893e851 (patch) | |
| tree | 940730ebfd71838f99afec5a322d8040c10d3c62 | |
| parent | c48218eae73f1a07fd23496837cc030d82845353 (diff) | |
Add ⌘K / Ctrl+K shortcut to focus sidebar ticker search
Injects a zero-height components.html block after the market bar that
listens for Cmd/Ctrl+K and focuses the sidebar search input by matching
its placeholder text.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | app.py | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -771,6 +771,25 @@ with st.container(): st.divider() +# ── ⌘K / Ctrl+K shortcut — focuses sidebar ticker search ───────────────────── +components.html( + "<script>" + "document.addEventListener('keydown', function(e) {" + " if ((e.metaKey || e.ctrlKey) && e.key === 'k') {" + " e.preventDefault();" + " var inputs = window.parent.document.querySelectorAll('input');" + " for (var i = 0; i < inputs.length; i++) {" + " if (inputs[i].placeholder && inputs[i].placeholder.indexOf('AAPL') > -1) {" + " inputs[i].focus(); inputs[i].select(); break;" + " }" + " }" + " }" + "});" + "</script>", + height=0, + scrolling=False, +) + # ── Main Content ────────────────────────────────────────────────────────────── if st.session_state["active_tab"] == "macro": |
