-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnav.js
More file actions
20 lines (19 loc) · 747 Bytes
/
nav.js
File metadata and controls
20 lines (19 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Javascript code to enable Arrow Key navigation
document.addEventListener("keydown", function(event) {
// Check if the pressed key is the left arrow key (key code 37)
if (event.code === "ArrowLeft") {
// Redirect to the previous page
var previousLink = document.querySelector(".nav-page-previous a");
if (previousLink) {
window.location.href = previousLink.getAttribute("href");
}
}
// Check if the pressed key is the right arrow key (key code 39)
else if (event.code === "ArrowRight") {
// Redirect to the next page
var nextLink = document.querySelector(".nav-page-next a");
if (nextLink) {
window.location.href = nextLink.getAttribute("href");
}
}
});