]> git.immae.eu Git - github/wallabag/wallabag.git/blame - themes/_global/js/keyboard.js
implement swipe gestures on mobile to go to next and previous articles
[github/wallabag/wallabag.git] / themes / _global / js / keyboard.js
CommitLineData
00dc7622
TC
1function navigateKeyboard(leftURL, rightURL) {
2 window.addEventListener("keypress", function (event) {
3 var key = event.which || event.keyCode; // event.keyCode is used for IE8 and earlier versions
00dc7622
TC
4 switch (key) {
5 case 37:
c34a8956 6 goLeft(leftURL);
00dc7622 7 break;
c34a8956 8
00dc7622 9 case 39:
c34a8956 10 goRight(rightURL);
00dc7622
TC
11 break;
12 }
13
14 }, false);
c34a8956
TC
15}
16
17function goLeft(leftURL) {
18 if (leftURL != "?view=view&id=") {
19 window.location = window.location.origin + window.location.pathname + leftURL;
20 }
21}
22
23function goRight(rightURL) {
24 if (rightURL != "?view=view&id=") {
25 window.location = window.location.origin + window.location.pathname + rightURL;
26 }
00dc7622 27}