Stop websites from hijacking keyboard

Part of this could be a Pit, so I’ll get that out of the way: websites, stop changing my goddamned keyboard shortcuts!

Anyway, some websites change keyboard behavior in manners that are quite frankly unnecessary and intrusive IMHO. For example, Youtube decides that HOME should start the video at 0:00 and END should go to the end (not sure why I’d want to do that), instead of going to the top/bottom of the page. Somewhat minor as I can click outside of the video to bypass it, but it still causes headaches from time to time.

Even worse: websites like New York Times and New York Magazine, where the RL arrow keys apparently go to the next or previous story. On this laptop the keys are small so as I scroll I inadvertently hit right often, causing the page to change.

Is there something I can change? Javascript? I’d prefer not to disable it completely if it can be helped.

I know you can use Noscript to disable javascript globally and then selectively enable it when you want. I’m also pretty sure, though not 100%, that you can allow it globally and selectively block it on certain websites, which would probably work better. To the best of my knowledge, there’s no way to stop Flash (e.g. youtube) from hijacking your keyboard.

Those sites where you need JavaScript just to do basic things should be nuked from outer space. There are getting to be more and more of them. If you disable JS in your browser (globally for for specific sites), you will probably eliminate a lot of that obnoxious behavior that they so diligently programmed into their sites – at the expense of probably causing a whole lot of stuff on the site not to work for you. Yes, Pit-worthy indeed!

I am seeing more and more sites are starting to do shit like this. I keep JS globally disabled in my browser all the time except when I know I need it (usually for paying bills on-line), and I am finding that more and more sites are becoming unusable because of it.

To really stop this behavior without breaking other JavaScript (i.e. removing keybinds but preserving other page functionality), you need to break the specific JavaScript calls that affect keybinds (and only them). The easiest way to do this is with GreaseMonkey and a pre-made script like this one:

That one is supposed to stop arrow keys and CTRL-F from being hijacked, but you can add additional keycodes to it yourself. If you’re good with JavaScript you can probably modify it to stop ALL keys from being rebound by websites.

I think it is the YouTube Flash video player app that is hijacking the Home and End keys. Adobe Flash apps are like little self-contained programs that run within your browser window.

The Flash video player app should only intercept the keystrokes if you’ve clicked on the video, making it the active element on the page. So click some whitespace on the page and you Home and End keys should work normally.

I’ve used NoScript but stopped for some reason, didn’t think of trying it again. That brings me to another peeve: nested scripts. Like it says “20 scripts can be blocked,” so you say “block all,” then 10 more pop up out of nowhere, then you have to do it again and again.

Thanks for the link, Reply. I’ll check it out. When is Ctrl+F hijacked? Is it like in embedded pdf where it can reference either searching page text or within the pdf?

No, I don’t think it can affect plugins like that (so YouTube would have to be set to html5 mode, for example). JavaScript only.

Nope. It happens in HTML5 mode, too. At least back when it was a Flash thing, you could click out to disable it.

The shortcuts are pretty stupid, anyways. You never have any reason to jump to the end of a video, since all it will show are the same videos you can see on the right. And you can trivially restart the video by reloading the page while it’s still running. Or, of course, a simple drag option with the mouse, the thing you have to use to interact with the video anyways. (Unless you want to hit tab 50 times.)

That said, Ctrl-Home and Ctrl-End are the universal shortcuts for the top and bottom of the page (or textbox). I didn’t even know you could use just Home and End.