Last active
July 20, 2024 06:44
-
-
Save eggbean/ba4daf82f132421c69dbd2c2e0b3e061 to your computer and use it in GitHub Desktop.
Userscript for Twitter Go Back with H key. Hosted at https://greasyfork.org/en/scripts/433523-twitter-go-back-with-h-key
This file contains hidden or 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 Twitter Go Back with H key | |
| // @namespace https://gist.github.com/eggbean/ba4daf82f132421c69dbd2c2e0b3e061/raw/twitter_go_back.user.js | |
| // @version 1.1 | |
| // @description Makes the unused H key a browser back button for better H,J,K,L keyboard navigation | |
| // @author https://github.com/eggbean | |
| // @match https://x.com/* | |
| // @icon https://x.com/favicon.ico | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| var gKeyPressed = false; | |
| addEventListener("keydown", function(e){ | |
| if (document.activeElement.tagName != 'INPUT' && document.activeElement.tagName != 'TEXTAREA' && document.activeElement.contentEditable != 'true') { | |
| switch (e.keyCode) { | |
| case 71: //"g" | |
| gKeyPressed = true; | |
| break; | |
| case 72: //"h" | |
| if (e.keyCode === 72 && gKeyPressed === false) { | |
| history.back(); | |
| } | |
| break; | |
| default: | |
| gKeyPressed = false; | |
| break; | |
| } | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment