From 657de68878f958c8c85550e68451ca5d381545ff Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 29 Nov 2025 18:54:07 -0500 Subject: [PATCH] Add keyboard navigation to more pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Books page: 2D grid navigation (up/down moves by row) - Fruits of Spirit: entry navigation - Tetragrammaton: section navigation - Verse of the Day: archive table navigation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- kjvstudy_org/templates/books.html | 39 +++++++++++++++++-- kjvstudy_org/templates/fruits_of_spirit.html | 37 ++++++++++++++++++ kjvstudy_org/templates/tetragrammaton.html | 33 ++++++++++++++++ kjvstudy_org/templates/verse_of_the_day.html | 40 ++++++++++++++++++++ 4 files changed, 146 insertions(+), 3 deletions(-) diff --git a/kjvstudy_org/templates/books.html b/kjvstudy_org/templates/books.html index 8ede80c..81e4132 100644 --- a/kjvstudy_org/templates/books.html +++ b/kjvstudy_org/templates/books.html @@ -304,11 +304,20 @@ {% endblock %} diff --git a/kjvstudy_org/templates/tetragrammaton.html b/kjvstudy_org/templates/tetragrammaton.html index 7292aff..2b070d9 100644 --- a/kjvstudy_org/templates/tetragrammaton.html +++ b/kjvstudy_org/templates/tetragrammaton.html @@ -151,6 +151,39 @@ document.addEventListener('DOMContentLoaded', function() { li.appendChild(a); tocList.appendChild(li); }); + + // Keyboard navigation for sections + const sections = Array.from(document.querySelectorAll('section h2')).map(h => h.closest('section')); + if (sections.length === 0) return; + + let selectedIndex = -1; + + function selectSection(index) { + if (selectedIndex >= 0 && selectedIndex < sections.length) { + sections[selectedIndex].style.outline = ''; + sections[selectedIndex].style.outlineOffset = ''; + } + selectedIndex = Math.max(0, Math.min(index, sections.length - 1)); + sections[selectedIndex].style.outline = '2px solid #4a7c59'; + sections[selectedIndex].style.outlineOffset = '4px'; + sections[selectedIndex].scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + + document.addEventListener('keydown', function(e) { + if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return; + + if (e.key === 'ArrowDown' || e.key === 'j') { + e.preventDefault(); + selectSection(selectedIndex < 0 ? 0 : selectedIndex + 1); + } else if (e.key === 'ArrowUp' || e.key === 'k') { + e.preventDefault(); + if (selectedIndex <= 0) selectSection(0); + else selectSection(selectedIndex - 1); + } else if (e.key === 'ArrowLeft' || e.key === 'h') { + e.preventDefault(); + history.back(); + } + }); }); {% endblock %} diff --git a/kjvstudy_org/templates/verse_of_the_day.html b/kjvstudy_org/templates/verse_of_the_day.html index 0ef1c2b..0f0b631 100644 --- a/kjvstudy_org/templates/verse_of_the_day.html +++ b/kjvstudy_org/templates/verse_of_the_day.html @@ -46,4 +46,44 @@ + + {% endblock %}