Add left-right arrows
[copyspeak.git] / src / copyspeak / static / js / word_detail.js
diff --git a/src/copyspeak/static/js/word_detail.js b/src/copyspeak/static/js/word_detail.js
new file mode 100644 (file)
index 0000000..dfb502b
--- /dev/null
@@ -0,0 +1,16 @@
+document.onkeydown = function(e) {
+    if (!e) e = window.event;
+    var keynum = e.keyCode ? e.keyCode : e.which; // IE vs others
+    switch (keynum) {
+        case 37:
+            var link = document.getElementById('previous-card');
+            link.setAttribute('class', 'active');
+            location.href = link.getAttribute('href');
+            return false;
+        case 39:
+            var link = document.getElementById('next-card');
+            link.setAttribute('class', 'active');
+            location.href = link.getAttribute('href');
+            return false;
+    }
+};