Created
December 1, 2022 12:10
-
-
Save THOUSAND-SKY/9bc859579a69a8c899f97e26d7c9fa0b to your computer and use it in GitHub Desktop.
j/k scrolling in firefox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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