Instagram Reels scrolling with W and S keys

101 views Asked by At

I'm trying to make a userscript for myself to scroll instagram reels with W and S keys. No matter how i try i haven't found a way to scroll reels with js. code below is my code to do this. i used this before to do the same thing for youtube shorts

const upkey = "KeyW";
const downkey = "KeyS";

document.addEventListener("keydown", function(event) {
  if (event.code === downkey) {
    const reelsContainer = document.querySelector('[tabindex="0"]');
    if (reelsContainer) {
      reelsContainer.scrollBy(0, 100);
      console.log("DOWN")
    }
  }
});

document.addEventListener("keyup", function(event) {
  if (event.code === upkey) {
    const reelsContainer = document.querySelector('[tabindex="0"]');
      console.log("u")
    if (reelsContainer) {
      reelsContainer.scrollBy(0, -100);
      console.log("UP")
    }
  }
});

I tried too many selectors but none of them worked. Is there a way to do this?

0

There are 0 answers