aboutsummaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorTyler <tyler@tylerhoang.xyz>2026-05-17 01:15:46 -0700
committerTyler <tyler@tylerhoang.xyz>2026-05-17 01:15:46 -0700
commitf013bf1243c191b8d6d23db1f144cb2f7270d063 (patch)
treef5741c7fbb76e525104abe7f14e96b7c44cfa2ae /app.py
parentc3268bc66c141dcaa647c674bad288586893e851 (diff)
Switch keyboard shortcut from Ctrl+K to / for ticker search focus
Ctrl+K conflicts with the browser address bar on Linux. / is the conventional global search shortcut (GitHub, Linear) and is not intercepted by browsers. Guard prevents firing while an input is focused. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'app.py')
-rw-r--r--app.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/app.py b/app.py
index 282b4e4..d22635b 100644
--- a/app.py
+++ b/app.py
@@ -775,11 +775,13 @@ st.divider()
components.html(
"<script>"
"document.addEventListener('keydown', function(e) {"
- " if ((e.metaKey || e.ctrlKey) && e.key === 'k') {"
- " e.preventDefault();"
+ " if (e.key === '/' && !e.metaKey && !e.ctrlKey && !e.altKey"
+ " && document.activeElement.tagName !== 'INPUT'"
+ " && document.activeElement.tagName !== 'TEXTAREA') {"
" 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) {"
+ " e.preventDefault();"
" inputs[i].focus(); inputs[i].select(); break;"
" }"
" }"