I’ve recently had to do a full audit of a website and was reminded of the fact that sometimes auditing some parts of web content accessibility guidelines (WCAG) can be difficult for external auditors with no direct contact with developers.
One of those success criteria is Success Criterion 2.1.4: Character Key Shortcuts (opens in new window) that explains: “If a keyboard shortcut is implemented in content using only letter (including upper- and lower-case letters), punctuation, number, or symbol characters, then at least one of the following is true: Turn off, Recap or Active only on focus”.
My first hunch was to check for the “accesskey” attributes on the page, but those are not affected here as they need to include modifier keys (like for example “Alt + Shift + accesskey”).
My second guess was that we can try to press all keys on the keyboard and check for effects. That would unfortunately not be enough as shortcuts might only be working in special situations that would require focus on distinct elements on the page.
Could we maybe test this automatically, with some JavaScript? Well there are some attempts to do it, like for example 3needs.org’s Character key shortcut test page (opens in new window), but as mentioned – it is not enough to only press all keys available to be certain that the site is passing or failing the success criterion.
Communication is key
A bit of a word play here – single key shortcuts and “communication is key” – but it really is. We can not be totally certain about the implementation without having access to source code – original, not minified and not obfuscated – JavaScript. That alone is also not very efficient – imagine reading all of the different parts that are not related to keyboard shortcuts – so as mentioned – communication is key.
We should be able to ask developers about it and check if they are aware of single key shortcuts. Their answer is based on trust and please be aware that some third party scripts installed on the site could also include keyboard shortcuts. So checking it with third party script providers would probably also make sense.