From 01e6f3b7ee437eb366189dbf8cc77f4381aca96c Mon Sep 17 00:00:00 2001 From: Thanos K Date: Sun, 13 Sep 2015 16:41:37 +0300 Subject: [PATCH] Added key navigation functionality --- item.php | 4 ++-- js/global.js | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/item.php b/item.php index ad5ad10..d12d1ac 100644 --- a/item.php +++ b/item.php @@ -58,10 +58,10 @@ if (isset($keys[array_search($item_num, $keys)-1])) { diff --git a/js/global.js b/js/global.js index 088136d..5129623 100644 --- a/js/global.js +++ b/js/global.js @@ -1 +1,18 @@ -/* No JS required any more */ \ No newline at end of file +/* No JS required any more */ + +document.onkeydown = function (e) { + switch (e.keyCode) { + case 37: + if (document.getElementById('previous_guideline') !== null) + window.location = document.getElementById('previous_guideline').href; + break; + + case 39: + if (document.getElementById('next_guideline') !== null) + window.location = document.getElementById('next_guideline').href; + break; + + default: + return; // Do nothing for the rest + } +};