From f852ad602ff7d018c68814e6a14fb78c2d24b28f Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 29 Nov 2025 23:25:34 -0500 Subject: [PATCH] Improve keyboard navigation consistency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verse page: - Now paragraph-based instead of section-based - Up/down moves through paragraphs, cross-refs, interlinear - Enter on interlinear enters word mode (like interlinear page) - Left/right for word navigation in word mode - Enter toggles word expansion - Escape exits modes Chapter page: - Added h/l vim keys for prev/next chapter - Added Escape to clear verse selection - Left now falls back to book page if no prev chapter Added Escape to clear selection on: - topic_detail.html - parable_detail.html - study_guide_detail.html (also added Enter to follow links) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- kjvstudy_org/templates/chapter.html | 22 ++- kjvstudy_org/templates/parable_detail.html | 7 + .../templates/study_guide_detail.html | 11 ++ kjvstudy_org/templates/topic_detail.html | 7 + kjvstudy_org/templates/verse.html | 176 ++++++++++++++---- 5 files changed, 182 insertions(+), 41 deletions(-) diff --git a/kjvstudy_org/templates/chapter.html b/kjvstudy_org/templates/chapter.html index cf9bbc7..b8dfe34 100644 --- a/kjvstudy_org/templates/chapter.html +++ b/kjvstudy_org/templates/chapter.html @@ -480,23 +480,35 @@ document.addEventListener('DOMContentLoaded', function() { if (link) window.location.href = link.href; } - // Left arrow: Previous chapter - if (e.key === 'ArrowLeft') { + // Left arrow or h: Previous chapter (when no verse selected, or at first verse) + if (e.key === 'ArrowLeft' || e.key === 'h') { + e.preventDefault(); const prevBtn = document.getElementById('prev-chapter'); if (prevBtn) { - e.preventDefault(); window.location.href = prevBtn.href; + } else { + // Go back to book page + window.location.href = '/book/{{ book }}'; } } - // Right arrow: Next chapter - if (e.key === 'ArrowRight') { + // Right arrow or l: Next chapter + if (e.key === 'ArrowRight' || e.key === 'l') { const nextBtn = document.getElementById('next-chapter'); if (nextBtn) { e.preventDefault(); window.location.href = nextBtn.href; } } + + // Escape: Clear selection + if (e.key === 'Escape') { + e.preventDefault(); + if (selectedVerseIndex >= 0 && selectedVerseIndex < verses.length) { + verses[selectedVerseIndex].classList.remove('selected'); + } + selectedVerseIndex = -1; + } }); // Click to select verse diff --git a/kjvstudy_org/templates/parable_detail.html b/kjvstudy_org/templates/parable_detail.html index d2b8cb7..7321ee8 100644 --- a/kjvstudy_org/templates/parable_detail.html +++ b/kjvstudy_org/templates/parable_detail.html @@ -151,6 +151,13 @@ e.preventDefault(); const link = verses[selectedIndex].querySelector('.verse-ref a'); if (link) window.location.href = link.href; + } else if (e.key === 'Escape') { + e.preventDefault(); + if (selectedIndex >= 0 && selectedIndex < verses.length) { + verses[selectedIndex].style.outline = ''; + verses[selectedIndex].style.outlineOffset = ''; + } + selectedIndex = -1; } }); })(); diff --git a/kjvstudy_org/templates/study_guide_detail.html b/kjvstudy_org/templates/study_guide_detail.html index 97771a5..0cd3b36 100644 --- a/kjvstudy_org/templates/study_guide_detail.html +++ b/kjvstudy_org/templates/study_guide_detail.html @@ -253,6 +253,17 @@ document.addEventListener('DOMContentLoaded', function() { } else if (e.key === 'ArrowLeft' || e.key === 'h') { e.preventDefault(); history.back(); + } else if (e.key === 'Enter' && selectedIndex >= 0) { + e.preventDefault(); + const link = sections[selectedIndex].querySelector('a'); + if (link) window.location.href = link.href; + } else if (e.key === 'Escape') { + e.preventDefault(); + if (selectedIndex >= 0 && selectedIndex < sections.length) { + sections[selectedIndex].style.outline = ''; + sections[selectedIndex].style.outlineOffset = ''; + } + selectedIndex = -1; } }); })(); diff --git a/kjvstudy_org/templates/topic_detail.html b/kjvstudy_org/templates/topic_detail.html index e8d0ccb..cf099f7 100644 --- a/kjvstudy_org/templates/topic_detail.html +++ b/kjvstudy_org/templates/topic_detail.html @@ -233,6 +233,13 @@ e.preventDefault(); const firstLink = sections[selectedIndex].querySelector('.verse-ref a'); if (firstLink) window.location.href = firstLink.href; + } else if (e.key === 'Escape') { + e.preventDefault(); + if (selectedIndex >= 0 && selectedIndex < sections.length) { + sections[selectedIndex].style.outline = ''; + sections[selectedIndex].style.outlineOffset = ''; + } + selectedIndex = -1; } }); })(); diff --git a/kjvstudy_org/templates/verse.html b/kjvstudy_org/templates/verse.html index e8dbe1b..ebe7722 100644 --- a/kjvstudy_org/templates/verse.html +++ b/kjvstudy_org/templates/verse.html @@ -812,63 +812,167 @@ {% endif %} {% endif %} - +