Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions templates/reader.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,27 @@
console.log("Could not find index for", filename);
}
}

// Keyboard navigation: arrow keys for previous/next chapter
document.addEventListener('keydown', function(e) {
// Only handle arrow keys when not typing in an input/textarea
const isTyping = e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.isContentEditable;
if (isTyping) return;

{% if prev_idx is not none %}
if (e.key === 'ArrowLeft') {
e.preventDefault();
window.location.href = "/read/{{ book_id }}/{{ prev_idx }}";
}
{% endif %}

{% if next_idx is not none %}
if (e.key === 'ArrowRight') {
e.preventDefault();
window.location.href = "/read/{{ book_id }}/{{ next_idx }}";
}
{% endif %}
});
</script>
</body>
</html>