3 ms·
> Be careful with this. Focusing a field is disconcerting if the user didn’t expect or desire it: on desktop computers, Space is commonly used as equivalent to
by oneeyedpigeon 5y ago
> Be careful with this. Focusing a field is disconcerting if the user didn’t expect or desire it: on desktop computers, Space is commonly used as equivalent to the Page Down key, but if you’ve focused something, it won’t do that; and on mobile devices, it’ll probably pop a keyboard open, perhaps blocking the user from seeing what’s actually going on. Only ever autofocus anything if an explicit user action has indicated they certainly want to interact with the form (some examples for the public internet: the user clicked a “log in” or “sign up” link, or you’re a search engine and they opened your front page; but if you’re an advertising landing page and have a form you want the user to fill out, don’t autofocus it; or if you have a search bar, don’t autofocus it).
I would argue that Space as an alias for Page Down is anachronistic and should be phased out. Without going any further down that particular rabbit hole, though, I agree with your overall point. I'd like more sites to provide this kind of behaviour as a preference. At the very least, give me a keyboard shortcut to focus your search input.
As an example, when I'm doing any PHP programming, I'm visiting php.net several times a day and 99.99% of the time, I want to use the search input immediately — even though I could want to scroll down to read previous version announcements. Maybe this fits into your 'search engine front page' case.
At least writing this ~~rant~~ response has made me go view source to find out the accesskey of that specific input, then go check the keyboard shortcut to activate an accesskey with my specific combination of OS and browser. Now I just need to force myself to use it until it's in muscle memory.
- chrismorgan 5y agoI mentioned Space as it’s the one I’m used to, but now I think back on it, all the other navigation keys get messed up inside a text box too (Up, Down, Left, Right, Home, End, Page Up, Page Down), so it’s not actually just about Space. Dunno why you’d consider Space for page navigation anachronistic. Space has always been a flexible “do all kinds of different things as useful” key, and Space/Shift+Space scrolling in focusable caretless content areas has always been popular and universally supported. But if we were talking about troublesome old key behaviours, I’d be with you on Backspace to go back being bad, which some browsers still do. (And in file managers, it goes up a directory, which is a useful operation, but you can use Alt+Up for that too. All up, if it weren’t for muscle memory, I’d say nuke non-deletionist Backspace behaviour, but muscle memory is a serious thing, so we’re stuck with Backspace being weird like this.) The php.net front page should certainly not have autofocus, though perhaps https://www.php.net/search.php https://www.php.net/search.php could.
- oneeyedpigeon 5y agoI trained myself out of using backspace for back precisely because of the number of times I'd end up in an input box and it would stop working. I use something like cmd-[ now, I think. I guess my point about space for pagedown is that it just seems unnecessary - I wonder how many keyboards don't have a PgDn key. Overloading printable characters, when non-printable alternatives exist, seems like a mistake.
- chrismorgan 5y agoMost laptop keyboards don’t have a Page Down key, though most that don’t will have Fn+Down emit Page Down. Space and Shift+Space are super useful on laptops especially.