Skip to content

Commit 6513d08

Browse files
chore(docs): Update explanation of keyboard navigation (#9833)
* chore(docs): Update explanation of keyboard navigation * chore(docs): add compliance info for keyboard nav * chore(docs): refer to command and control instead of meta
1 parent 5a63e99 commit 6513d08

2 files changed

Lines changed: 93 additions & 24 deletions

File tree

packages/docs/docs/guides/configure/web/keyboard-nav.mdx

Lines changed: 82 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,88 @@ title: Keyboard navigation
44
image: images/blockly_banner.png
55
---
66

7-
# Keyboard navigation
8-
9-
Blockly provides keyboard navigation through the `@blockly/keyboard-navigation`
10-
plugin. This code uses the [focus system](/guides/configure/web/focus)
11-
and will eventually be integrated into Blockly core.
12-
13-
You can [download the plugin from
14-
npm](https://www.npmjs.com/package/@blockly/keyboard-navigation) or get the code
15-
from the [`blockly-keyboard-experimentation`
16-
repository](https://github.com/RaspberryPiFoundation/blockly-keyboard-experimentation/) on
17-
GitHub.
18-
19-
If you want to play with the plugin, visit the [accessibility plugin
20-
playground](https://raspberrypifoundation.github.io/blockly-keyboard-experimentation/).
21-
22-
- To get started, click the workspace or press `tab` until you reach the
23-
workspace.
24-
- Use the arrow keys to move around.
25-
- Press `T` to open the toolbox.
26-
- Press `Enter` or `Space` to edit or confirm.
27-
- Press `/` for a complete list of keyboard commands.
28-
29-
For more information about our accessibility projects, visit [our accessibility
30-
page](https://developers.google.com/blockly/accessibility#projects).
7+
# Using Blockly with the keyboard
8+
9+
Blockly’s keyboard navigation and screen reader support are implemented around
10+
the concept of a **cursor** representing the user’s location on the workspace.
11+
The user can move the cursor with either the keyboard or with the mouse, just
12+
like in a text editor. Keyboard shortcuts act on the item under the cursor.
13+
The screen reader reads information about the item under the cursor.
14+
15+
## Basic operation
16+
17+
A user has to be able to easily complete five basic operations when using
18+
Blockly. Let’s walk through those operations, and how to accomplish them with
19+
the keyboard.
20+
21+
- Read an existing program by using the arrow keys to move around the workspace.
22+
- **Up** and **down** let you move line-by-line, while **left** and **right**
23+
move within a line of code.
24+
- Blockly creates an appropriate text description of each cursor location that
25+
can be read out by a screen reader.
26+
- Edit values on blocks by moving the cursor to a modifiable value and pressing
27+
**enter** to open the field editor.
28+
- Move blocks in the workspace to create or modify a program by pressing **M**
29+
to pick up a block, moving it with the **arrow keys**, and pressing **enter** to
30+
drop the block in a new location.
31+
- By default the arrow keys move a block between legal locations on the
32+
workspace.
33+
- Holding a modifier key moves the block as though it were being dragged with
34+
a mouse.
35+
- Insert blocks from the toolbox to create or modify a program by pressing **T**
36+
to open the toolbox and using the **arrow keys** to select a block to insert.
37+
- Pressing **enter** moves the block to the workspace in move mode.
38+
- Delete blocks to modify a program by moving the cursor to a block and
39+
pressing **delete** or **backspace**.
40+
41+
### Try it!
42+
43+
Try it yourself on the [Blockly playground](https://raspberrypifoundation.github.io/blockly/packages/blockly/tests/playground.html):
44+
- Click on the workspace or press **tab** to move focus through the page to the workspace.
45+
- Press **T** to open the toolbox and use the **arrow keys** to select a block.
46+
- Press **enter** to insert the block.
47+
- Repeat to build a program.
48+
- Use the **arrow keys** to navigate to a field and press **enter** to edit the
49+
field value.
50+
51+
## Advanced operation
52+
53+
Blockly provides many other keyboard shortcuts, including **I** to get
54+
information about the cursor location and **control + enter** (Windows) or
55+
**command + enter** (Mac) to open the context menu. Cut, copy/paste, and
56+
undo/redo all follow conventions for keyboard shortcuts.
57+
58+
## Why not tab?
59+
60+
Blockly does not follow the convention to navigate around a page with **tab**
61+
and **shift + tab** because block code cannot usefully be compressed into a
62+
linear navigation order. Blocks can contain other blocks, both horizontally and
63+
vertically, and require at least two dimensions to navigate. Tests with learners
64+
showed that arrow key navigation supported their understanding of programming
65+
concepts.
66+
67+
From a computer science perspective a block program is an abstract syntax tree.
68+
Arrow keys allow for navigation up/down and left/right within the tree, while
69+
tab navigation only supports a fixed order.
70+
71+
## Technical details
72+
73+
Blockly keyboard navigation uses the [focus system](/guides/configure/web/focus)
74+
to manage the location of the cursor. This code will be released in Blockly v13
75+
(targeted release: June 2026).
76+
77+
### Compliance
78+
79+
Blockly's keyboard navigation system meets the following WCAG criteria:
80+
- [1.3.2 Meaningful Sequence (Level A)](https://www.w3.org/WAI/WCAG22/Understanding/meaningful-sequence)
81+
- [2.1.1 Keyboard (Level A)](https://www.w3.org/WAI/WCAG22/Understanding/keyboard)
82+
- [2.1.2 No Keyboard Trap (Level A)](https://www.w3.org/WAI/WCAG22/Understanding/no-keyboard-trap)
83+
- [2.1.4 Character Key Shortcuts (Level A)](https://www.w3.org/WAI/WCAG22/Understanding/keyboard-no-exception)
84+
- Character key shortcuts are active only on workspace focus.
85+
- [2.4.3 Focus Order (Level A)](https://www.w3.org/WAI/WCAG22/Understanding/focus-order)
86+
- [2.4.7 Focus Visible (Level AA)](https://www.w3.org/WAI/WCAG22/Understanding/focus-visible)
87+
- [3.2.4 Consistent Identification (Level AA)](https://www.w3.org/WAI/WCAG22/Understanding/consistent-identification)
88+
- [4.1.2 Name, Role, Value (Level A)](https://www.w3.org/WAI/WCAG22/Understanding/name-role-value)
3189

3290
:::note
3391
The 0.6 version of the keyboard navigation plugin that existed prior to

packages/docs/sidebars.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,17 @@ const sidebars = {
12731273
},
12741274
],
12751275
},
1276+
{
1277+
type: 'category',
1278+
label: 'Accessibility',
1279+
items: [
1280+
{
1281+
type: 'doc',
1282+
label: 'Compliance',
1283+
id: 'guides/app-integration/compliance',
1284+
},
1285+
],
1286+
},
12761287
{
12771288
type: 'doc',
12781289
label: 'Attribute Blockly',

0 commit comments

Comments
 (0)