aboutsummaryrefslogtreecommitdiffhomepage
path: root/themes/_global/js/keyboard.js
blob: 26978cb296a5d2c24af7b1e4fc2c47f277d8cafb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function navigateKeyboard(leftURL, rightURL) {
  window.addEventListener("keypress", function (event) {
    var key = event.which || event.keyCode; // event.keyCode is used for IE8 and earlier versions
    console.log("key pressed : " + key);
    switch (key) {
      case 37:
        // left arrow
        if (leftURL != "?view=view&id=") {
          window.location = window.location.origin + window.location.pathname + leftURL;
        }
      break;
        /*
        case 38:
        // top arrow
        window.location = window.location.origin + window.location.pathname + window.location.search + "#top";
        break;
        */
      case 39:
        //right arrow
        if (rightURL != "?view=view&id=") {
        window.location = window.location.origin + window.location.pathname + rightURL;
        }
      break;
    }

  }, false);
}