From 6e62d68ec907e1c6d473c0c4c52f5d27fa3cd50d Mon Sep 17 00:00:00 2001 From: Eldritch Cheese Date: Fri, 23 Feb 2018 22:12:36 -0800 Subject: [PATCH] Updates keynav.js to preserve browser forward/back functions. --- js/keynav.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/js/keynav.js b/js/keynav.js index 7b102b0..7e91ecb 100644 --- a/js/keynav.js +++ b/js/keynav.js @@ -1,18 +1,30 @@ jQuery(document).ready(function () { + var alt_down = false; + + jQuery(document).keyup(function(e) { + if(document.querySelector('#comment:focus,#author:focus,#email:focus,#url:focus,#mcspvalue:focus')) return; + + if(e.which == 18) { + alt_down = false; + } + }); + jQuery(document).keydown(function(e) { var url = false; - if(document.querySelector('#comment:focus,#author:focus,#email:focus,#url:focus,#mcspvalue:focus')) return; + if(document.querySelector('#comment:focus,#author:focus,#email:focus,#url:focus,#mcspvalue:focus') || alt_down) return; if (e.which == 37) { // Left arrow key code url = jQuery('a.comic-nav-previous').attr('href'); } else if (e.which == 39) { // Right arrow key code url = jQuery('a.comic-nav-next').attr('href'); - } + } else if (e.which == 18) { // Alt key code + alt_down = true; + } if (url) { window.location = url; } }); -}); \ No newline at end of file +});