Blocked event
A blocked event makes no changes to the content of the web page.
No keyboard shortcut uses only printable characters
This rule checks that if keyboard shortcuts are implemented using only printable characters, then there is a mechanism to disable the shortcut, or to remap the shortcut to use one or more non-printable character keys, or the shortcut for a user interface component is only available when that component has focus.
This rule applies to any keyboard event for which all of the following is true:
key
is a printable character key; andgetModifierState
returns false
for each of the valid modifier keys; andFor each test target at least one of the following is true:
getModifierState
method returns false
for each of the valid modifier keys; orwidget
.Currently keyboard events only support the types keydown
and keyup
. Keyboard events of type keypressed
are considered legacy keyboard events and are thus ignored by this rule.
The instruments used to pass this rule (if any), must meet all level A Success Criteria in order to fully satisfy Success Criterion 2.1.4: Character Key Shortcuts. These extra requirements are left out of this rule, and should be tested separately.
This rule allows changes to the content when a user interface component has focus to meet the "Active only on focus" requirement from Success Criterion 2.1.4. As explained in the Event dispatch and DOM event flow section of the UI Events Working Draft, each keyboard event is dispatched to an event target. The event target is the element that has focus. As such, the "Active only on focus" requirement from Success Criterion 2.1.4 is implied by saying that the event target is an inheriting semantic widget
.
The "Turn off" and "Remap" requirements from Success Criterion 2.1.4 are combined in the disable/remap item of the Expectation section. For the disable requirement, changes in content that are made through keyboard events with a printable character value for the key
attribute and a getModifierState
return value of false
for each of the valid modifier keys effectively need to be blocked (in other words, turned off or disabled). The remap requirement unblocks the events if the getModifierState
query returns true
for at least one of the valid modifier keys. Once the getModifierState
returns true
for at least one of the valid modifier keys of a keyboard event, such keyboard event is no longer applicable for the rule and it passes the "Remap" requirement from Success Criterion 2.1.4.
This HTML document is listening to keyboard events for which the attribute key
is a printable character and the method getModifierState
returns false
, and which cause changes in content. There exists an instrument to disable the keyboard event so that same key events are blocked unless getModifierState("Control")
returns true
, therefore meeting the disable/remap expectation.
<html>
<head>
<title>Passed Example 1</title>
<script src="/test-assets/ffbc54/shortcut.js"></script>
</head>
<body onload="registerShortcut({id: 'singleShortcut', shortcutKey: '+'}); activateShortcuts();">
<label for="target">Add to list (press "+" to add):</label>
<input type="text" id="target" />
<div>
<div>Remap shortcut</div>
<div>
<label>
<input id="remap" type="checkbox" onclick="toggleModifier('singleShortcut', this.checked)" />
Use "ctrl" key together with the "+" key
</label>
</div>
</div>
<br />
<div>
To do list
</div>
<ul id="list"></ul>
</body>
</html>
This HTML document is listening to keyboard events for which the attribute key
is a printable character and the method getModifierState
returns false
, and which cause changes in content. There exists an instrument to disable the keyboard event. A disabled event implies that the event is disabled when the getModifierState
method returns false
.
<html>
<head>
<title>Passed Example 2</title>
<script src="/test-assets/ffbc54/shortcut.js"></script>
</head>
<body onload="registerShortcut({id: 'singleShortcut', shortcutKey: '+'}); activateShortcuts();">
<label for="target">Add to list (press "+" to add):</label>
<input type="text" id="target" />
<label>
<input type="checkbox" onclick="toggleDisabled('singleShortcut', !this.checked)" checked />
Toggle single character keyboard shortcut
</label>
<br />
<div>
To do list
</div>
<ul id="list"></ul>
</body>
</html>
This HTML document is listening to keyboard events for which the attribute key
is a printable character and the method getModifierState
returns false
, and which cause changes in content. For each keyboard event causing changes in content, there exists an instrument to disable it so that same key events are blocked unless getModifierState("Control")
returns true
, therefore meeting the disable/remap expectation.
<html>
<head>
<title>Passed Example 3</title>
<script src="/test-assets/ffbc54/shortcut.js"></script>
</head>
<body
onload="registerShortcut({id: 'firstShortcut', shortcutKey: '+'}); registerShortcut({id: 'secondShortcut', shortcutKey: 'a'}); activateShortcuts();"
>
<label for="target">Add to list (press "+" or "a" to add):</label>
<input type="text" id="target" />
<div>
<div>Remap shortcut</div>
<div>
<label>
<input id="remap1" type="checkbox" onclick="toggleModifier('firstShortcut', this.checked)" />
Use "ctrl" key together with the "+" key
</label>
<label>
<input id="remap2" type="checkbox" onclick="toggleModifier('secondShortcut', this.checked)" />
Use "ctrl" key together with the "a" key
</label>
</div>
</div>
<br />
<div>
To do list
</div>
<ul id="list"></ul>
</body>
</html>
This HTML document is listening to keyboard events for which the attribute key
is a printable character and the method getModifierState
returns false
, and which cause changes in content. There exists an instrument to disable those keyboard events that cause changes in content so that same key events are blocked unless getModifierState("Control")
returns true
. In this example, the same instrument is used to remap all keyboard events.
<html>
<head>
<title>Passed Example 4</title>
<script src="/test-assets/ffbc54/shortcut.js"></script>
</head>
<body
onload="registerShortcut({id: 'firstShortcut', shortcutKey: '+'}); registerShortcut({id: 'secondShortcut', shortcutKey: 'a'}); activateShortcuts();"
>
<label for="target">Add to list (press "+" or "a" to add):</label>
<input type="text" id="target" />
<div>
<div>Remap shortcut</div>
<div>
<label>
<input
id="remap"
type="checkbox"
onclick="toggleModifier('firstShortcut', this.checked); toggleModifier('secondShortcut', this.checked);"
/>
Use "ctrl" key together with the "+" or "a" key
</label>
</div>
</div>
<br />
<div>
To do list
</div>
<ul id="list"></ul>
</body>
</html>
This HTML document is listening to keyboard events for which the attribute key
is a printable character and the method getModifierState
returns false
, and which cause changes in content, but the events are blocked when no widget
has focus.
<html>
<head>
<title>Passed Example 5</title>
<script src="/test-assets/ffbc54/shortcut.js"></script>
</head>
<body onload="registerShortcut({shortcutKey: '+', focusOnly: true}); activateShortcuts();">
<label for="target">Add to list (press "+" to add):</label>
<input type="text" id="target" />
<br />
<div>
To do list
</div>
<ul id="list"></ul>
</body>
</html>
This HTML document is listening to keyboard events for which the attribute key
is a printable character and the method getModifierState
returns false
, and which cause changes in content. There exists a set of clearly labeled instruments to disable or to remap the keyboard event so that same key events are blocked unless getModifierState("Control")
returns true
.
<html>
<head>
<title>Passed Example 6</title>
<link rel="stylesheet" type="text/css" href="/test-assets/ffbc54/styles.css" />
<script src="/test-assets/ffbc54/shortcut.js"></script>
</head>
<body onload="registerShortcut({id: 'singleShortcut', shortcutKey: '+'}); activateShortcuts();">
<div id="overlay">
<p>Disable/remap shortcut</p>
<label>
<input type="checkbox" onclick="toggleDisabled('singleShortcut', !this.checked)" checked />
Toggle single character keyboard shortcut
</label>
<br />
<label>
<input id="remap" type="checkbox" onclick="toggleModifier('singleShortcut', this.checked)" />
Use "ctrl" key together with the "+" key
</label>
<br />
<button onclick="closeModal();">Dismiss</button>
</div>
<p>To control the shortcuts activate the "Control shortcuts" button.</p>
<input type="button" onclick="openModal()" value="Control shortcuts" />
<label for="target">Add to list (press "+" to add):</label>
<input type="text" id="target" />
<div>
To do list
</div>
<ul id="list"></ul>
</body>
</html>
This HTML document is listening to keyboard events for which the attribute key
is a printable character and the method getModifierState
returns false
, and which cause changes in content. There is no instrument to disable or remap the keyboard event and the keyboard events are not blocked when no widget
has focus.
<html>
<head>
<title>Failed Example 1</title>
<script src="/test-assets/ffbc54/shortcut.js"></script>
</head>
<body onload="registerShortcut({shortcutKey: '+', disabled: false}); activateShortcuts();">
<label for="target">Add to list (press "+" to add):</label>
<input type="text" id="target" />
<br />
<div>
To do list
</div>
<ul id="list"></ul>
</body>
</html>
This HTML document is listening to keyboard events for which the attribute key
is a printable character and the method getModifierState
returns false
, and which cause changes in content. There is an instrument to disable or remap the keyboard event so that same key events are blocked unless getModifierState("Control")
returns true
, but the instrument is not in a clearly labeled location.
<html>
<head>
<title>Failed Example 2</title>
<link rel="stylesheet" type="text/css" href="/test-assets/ffbc54/styles.css" />
<script src="/test-assets/ffbc54/shortcut.js"></script>
</head>
<body onload="registerShortcut({id: 'singleShortcut', shortcutKey: '+'}); activateShortcuts();">
<div id="overlay">
<p>Disable/remap shortcut</p>
<label>
<input type="checkbox" onclick="toggleDisabled('singleShortcut', !this.checked)" checked />
Toggle single character keyboard shortcut
</label>
<br />
<label>
<input id="remap" type="checkbox" onclick="toggleModifier('singleShortcut', this.checked)" />
Use "ctrl" key together with the "+" key
</label>
<br />
<button onclick="closeModal();">Dismiss</button>
</div>
<input type="button" onclick="openModal()" value="Open modal" />
<label for="target">Add to list (press "+" to add):</label>
<input type="text" id="target" />
<div>
To do list
</div>
<ul id="list"></ul>
</body>
</html>
This HTML document has a keyboard event dispatched to an event target but it only causes changes in content if the event's attribute key
is not a printable character (in this example, the Escape key).
<html>
<head>
<title>Inapplicable Example 1</title>
<script src="/test-assets/ffbc54/shortcut.js"></script>
</head>
<body onload="registerShortcut({shortcutKey: 'Escape'}); activateShortcuts();">
<label for="target">Add to list (press "esc" to add):</label>
<input type="text" id="target" />
<br />
<div>
To do list
</div>
<ul id="list"></ul>
</body>
</html>
This HTML document has a keyboard event dispatched to an event target with the attribute key
being a printable character but it does not cause changes in content unless the getModifierState
returns true
.
<html>
<head>
<title>Inapplicable Example 2</title>
<script src="/test-assets/ffbc54/shortcut.js"></script>
</head>
<body onload="registerShortcut({shortcutKey: '+', ctrlKey: true}); activateShortcuts();">
<label for="target">Add to list (press "ctrl" and "+" to add):</label>
<input type="text" id="target" />
<br />
<div>
To do list
</div>
<ul id="list"></ul>
</body>
</html>
A blocked event makes no changes to the content of the web page.
A event originated change in the content of a web page occurs when, by comparing the web page before and 1 minute after the event firing, at least one of the following occurs:
Assumptions:
Secondary information and alternative controls of functionality are often not displayed together with primary information or functionality. For example, an option to change a web page to dark mode may be placed on an options page instead of being available on every page and page state of a website. Another example is a maps application, where, instead of using GPS, an option is available in a dropdown menu to set the current location of the device. Such content should be placed in a clearly labeled location.
The location of a target is said to be clearly labeled when the target can be found by activating "identifiable" instruments which either lead the user to find the target, or to another page or page state from which this action can be repeated until the target is found.
Whether or not the content is "clearly labeled" depends on the starting point of the search. If page A has a link which clearly "identifies" some piece of content, then the location of the content is clearly labeled. Page B, which can be in the same website, may not have such a link or may have a link with a link text that does not "identify" target content or which can be interpreted to "identify" more than one target, and so the location of the content starting from page B is not clearly labeled.
For the purpose of this definition, an instrument is identifiable if any text or other content with a text alternative, allows any user to identify an element with a semantic role that inherits from widget
.
A web page changes state when the document's body changes without a change in the document's URL.
An element with an inheriting semantic role of X is any element with a non-abstract semantic role that inherits from X, or is the same as X.
Example: An "inheriting semantic link" is any element that either has the semantic role of link
or a semantic role that inherits from the link
role, such as doc-biblioref.
An HTML element that when activated allows an end-user to achieve an objective.
Note: Any rule that uses this definition must provide an unambiguous description of the objective the instrument is used to achieve.
This definition is a more restrictive version of WCAG's definition of mechanism, notably restricting it to the current document. WCAG has a note that "The mechanism needs to meet all success criteria for the conformance level claimed." This includes all the level A criteria such as Success Criterion 2.1.1 Keyboard (the mechanism must be keyboard accessible) or Success Criterion 4.1.2 Name, Role, Value (the mechanism must be exposed to assistive technologies and have an accessible name). This definition, and the rules using it, leaves these extra requirements out. This avoids reporting the same component twice for the same reason (e.g., missing an accessible name) under two different rules and Success Criteria, and helps pinpoint the error related to each Success Criterion. Instruments should nonetheless be fully accessible at the correct conformance level (depending on the rule using them).
An outcome is a conclusion that comes from evaluating an ACT Rule on a test subject or one of its constituent test target. An outcome can be one of the three following types:
Note: A rule has one passed
or failed
outcome for every test target. When there are no test targets the rule has one inapplicable
outcome. This means that each test subject will have one or more outcomes.
Note: Implementations using the EARL10-Schema can express the outcome with the outcome property. In addition to passed
, failed
and inapplicable
, EARL 1.0 also defined an incomplete
outcome. While this cannot be the outcome of an ACT Rule when applied in its entirety, it often happens that rules are only partially evaluated. For example, when applicability was automated, but the expectations have to be evaluated manually. Such "interim" results can be expressed with the incomplete
outcome.
A printable character is a character that occupies a printing position on a display.
These characters correspond to the following Unicode categories:
Two keyboard events are same key events if they have the same value for all the following attributes:
key
code
location
repeat
isComposing
The semantic role of an element is determined by the first of these cases that applies:
This definition can be used in expressions such as "semantic button
" meaning any element with a semantic role of button
.
aria-hidden="true"
attribute. The WAI ARIA specification does not explain how to solve it. Some browsers give precedence to the element being focusable (and expose it in the accessibility tree) while some give precedence to the aria-hidden
attribute (and hide the element).A set of clearly labeled instruments is a set of instruments, where each instrument is in the same web page as the test target or can be found in a clearly labeled location from that web page.
An HTML web page is the set of all fully active documents which share the same top-level browsing context.
Note: Nesting of browsing context mostly happens with iframe
and object
. Thus a web page will most of the time be a "top-level" document and all its iframe
and object
(recursively).
Note: Web pages as defined by WCAG are not restricted to the HTML technology but can also include, e.g., PDF or DOCX documents.
Note: Although web pages as defined here are sets of documents (and do not contain other kind of nodes), one can abusively write that any node is "in a web page" if it is a shadow-including descendant of a document that is part of that web page.
This section is not part of the official rule. It is populated dynamically and not accounted for in the change history or the last modified date. This section will not be included in the rule when it is published on the W3C website.
Implementation reports are not provided for this rule.