Skip to content

Instantly share code, notes, and snippets.

@THOUSAND-SKY
Created December 1, 2022 12:10
Show Gist options
  • Save THOUSAND-SKY/9bc859579a69a8c899f97e26d7c9fa0b to your computer and use it in GitHub Desktop.
Save THOUSAND-SKY/9bc859579a69a8c899f97e26d7c9fa0b to your computer and use it in GitHub Desktop.
j/k scrolling in firefox
// ==UserScript==
// @name scrolling
// @match *://*/*
// @version 1.0
// ==/UserScript==
const s = (e, dir) => {
e.preventDefault()
e.stopPropagation()
window.scrollBy({
behavior: "smooth",
top: dir
})
}
const scrollAmount = 300
window.addEventListener("keydown", e => {
if (e.ctrlKey) {
if (e.key === "k")
s(e, -scrollAmount)
else if (e.key === "j")
s(e, scrollAmount)
}
}, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment