Making Home/End work normally in Discord

Two screenshots show what this post is about: the new behaviour is that pressing Home in a word-wrapped paragraph moves the caret to the beginning of the paragraph. With change reverted, pressing Home moves the caret to the beginning of the line again.

With sufficiently poor luck you might have already noticed The New Thing in the latest Discord update: Home/End keys now navigate to the start/end of the current paragraph instead of a line.

This is a tiny post about fixing that.


First, the code. You could paste it straight into a JavaScript console if you know what you're doing, or install it as a userscript.

let attrMark = "yal-undo-home-end";
let query = `div[role="textbox"]:not([${attrMark}])`;
setInterval(() => {
	for (let tb of document.querySelectorAll(query)) {
		tb.setAttribute(attrMark, "");
		tb.addEventListener("keydown", (e) => {
			if (e.key == "Home" || e.key == "End") {
				e.stopImmediatePropagation();
			}
		});
	}
}, 300);

Not a whole lot of code here!

It periodically finds textboxes that have not yet been tagged, tags them, and gives them a keyboard event listener that prevents the events for Home/End keys from making it to Discord's event handlers.

As for why would Discord do this to you, according to a somewhat LLM-looking support ticket reply (#57507099), it's intended and unfortunately there is no specific information on justification.

So there's that. Maybe they'll reconsider if you scream at them really loudly.

Related posts:

2 thoughts on “Making Home/End work normally in Discord

  1. Another way to work around this is…

    Accessibility -> Use the legacy chat input

    …though you lose all the inline formatting previews like -# shrinking text, emoji, etc. But if you’re on the desktop client instead of the browser it’s another workaround for now.

    • Oh, that’s good to know! I tried Chat ➜ Text box, which did disable inline element display but did not disable this behavior change.

Leave a Reply to WolfWings Cancel reply

Your email address will not be published. Required fields are marked *
Note: JavaScript is currently required to post comments.

This site uses Akismet to reduce spam. Learn how your comment data is processed.