handle left/right arrow keys for album nav

This commit is contained in:
Nick Pegg 2024-08-04 08:35:45 -07:00
parent ac08b1fc84
commit d1dcb610d6
2 changed files with 20 additions and 1 deletions

View file

@ -3,13 +3,17 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{{ static_dir }}/index.css" type="text/css">
<title>My Photos</title>
<link rel="stylesheet" href="{{ static_dir }}/index.css" type="text/css">
</head>
<body>
<div id="content">
{% block content %}
{% endblock %}
</div>
<script type="text/javascript">
{% block js %}
{% endblock %}
</script>
</body>
</html>

View file

@ -1,5 +1,20 @@
{% extends "base.html" %}
{% block js %}
// Do left/right navigation on keypresses
document.onkeydown = function(event) {
if (event.key == "ArrowLeft") {
{% if prev_image %}
location.href = "{{prev_image.html_filename()}}";
{% endif %}
} else if (event.key == "ArrowRight") {
{% if next_image %}
location.href = "{{next_image.html_filename()}}";
{% endif %}
}
}
{% endblock %}
{% block content %}
<div id="nav">
<div>