[Solved] Need some tips using Key event & tab

Discussion in 'Help & Guides' started by Davinna, Feb 10, 2017.

  1. Davinna

    Davinna Well-Known Turker

    Messages:
    371
    Gender:
    Female
    Ratings:
    +441
    I'm working on writing a script that works on RnR Caption Hits. I'd like to be able to use the tab key and scroll down the page from document box to document box. Or, would it be easier to tab/scroll from one "upper" radio to the next "upper" radio button?

    Code:
    $(document).keyup(function(event) {
        if(event.which == 9)
        {
            console.log(event);
        }
    });
     

    Attached Files:

  2. Kadauchi

    Kadauchi Administrator Former MTG MotM

    Messages:
    4,367
    Ratings:
    +8,589
    Use a counter to keep track of what document box you want to scroll to the next one.

    Code:
    let i = 0;
    const docbox = document.getElementsByClassName(`documentbox`);
    
    document.addEventListener(`keydown`, function (event) {
      const key = event.key;
    
      if (key === `Tab`) {
        if (docbox[++ i]) docbox[i].scrollIntoView();
      }
    });
     
    • Today I Learned Today I Learned x 3