| Total Complexity | 6 |
| Complexity/F | 3 |
| Lines of Code | 28 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | $(function() { |
||
| 2 | window.addEventListener("keydown", function (event) { |
||
| 3 | if (event.defaultPrevented) { |
||
| 4 | return; // Do nothing if the event was already processed |
||
| 5 | } |
||
| 6 | var url; |
||
| 7 | switch (event.key) { |
||
| 8 | case "Left": // IE/Edge specific value |
||
| 9 | case "ArrowLeft": |
||
| 10 | url = $("#navigatePrev").attr('href'); |
||
| 11 | if (url) { |
||
| 12 | window.location.href = url; |
||
| 13 | } |
||
| 14 | break; |
||
| 15 | case "Right": // IE/Edge specific value |
||
| 16 | case "ArrowRight": |
||
| 17 | url = $("#navigateNext").attr('href'); |
||
| 18 | break; |
||
| 19 | default: |
||
| 20 | return; // Quit when this doesn't handle the key event. |
||
| 21 | } |
||
| 22 | if (url) { |
||
| 23 | window.location.href = url; |
||
| 24 | } |
||
| 25 | // Cancel the default action to avoid it being handled twice |
||
| 26 | event.preventDefault(); |
||
| 27 | }, true); |
||
| 28 | }); |
||
| 29 |