Previous/Next Chapter arrow keys javascript

#1
Here is some javascript for those that want to use the left and right arrow keys on your keyboard to goto the previous or next chapter.

This code is meant to be used with Chrome using an extension like Custom Javascript but should be easily adaptable for other browsers.

Replace '& lt;' with <

Code:
function kdown(a){
    var e = document.event ? document.event : a;
    var alist = document.getElementsByTagName( "a" );
    if(e.keyCode == 39){
        // next key
        for(i=0;i &lt; alist.length;i++){
           var a1 = alist[i];
           if(a1.innerText == "Next Chapter" ){
               location.href=a1.href;
           }
       }
    }else if(e.keyCode == 37){
       // Previous Chapter (Left arrow key)
       for(i=0;i &lt; alist.length;i++){
            var a1 = alist[i];
            if(a1.innerText == "Previous Chapter" ){
                location.href=a1.href;
            }
         }
    }
}
document.addEventListener("keydown", kdown);

Re: Previous/Next Chapter arrow keys javascript

#7

kanadaj Wrote: You can now disable the left/right key navigation via https://www.royalroad.com/account/options


- I have noticed weird glitch - if you disable it:
   [ ] Enable chapter navigation via the keyboard Left and Right Keys
every now and then - it gets reset back to enabled state (same with: Width to 80%).
Which is a bit weird, since does not appear to be stored in cookies..

Plus, that navigation really gets in the way when writing comments..