WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Links and Spacebar

for

From: Birkir R. Gunnarsson
Date: Feb 3, 2020 10:59AM


Agree with Steve
If you repurpose a link as a button you need Javascript that checks if
the spacebar is pressed and executes the onclick event on the link if
it is pressed.
You can tie the Javascript selectors to all elements with
role="button" (something you have to add to links anyway when you
repurpose them as buttons).
Note: A screen reader user doesn't care, because most screen readers
are configured to execute the onclick event if either the enter or
spacebar are pressed when in browse mode (this can be changed in
screen reader settings and this does not apply in application/forms
mode).
I'm not implying you are only asking with the screen reader usre
experience in mind (accessibility is about a lot more than screen
reader users, as we all know and agree) but this behavior is specific
to screen readers and people testing webpages for keyboarde
accessibility often fall into the trap of having screen readers
running when they do it.
gives a confusing

On 2/3/20, Steve Green < <EMAIL REMOVED> > wrote:
> On all Windows browsers (and maybe Mac, but I have not checked), the
> spacebar scrolls the page down unless the focus is on certain elements such
> as checkboxes and buttons. That said, I have never seen anyone do this in 15
> years of user testing.
>
> If all links responded to the spacebar I don't think anyone would notice.
> Nevertheless, I am not keen on making exceptions like this, so I would
> advocate against it. It should be easy to only have the spacebar work with
> links that are styled as buttons.
>
> Steve Green
> Managing Director
> Test Partners Ltd
>
>
>