|
| 1 | +--- |
| 2 | +description: Best practices for making a Blockly-based application accessible. |
| 3 | +title: Accessibility best practices |
| 4 | +image: images/blockly_banner.png |
| 5 | +--- |
| 6 | + |
| 7 | +# Accessibility best practices |
| 8 | + |
| 9 | +Since Blockly is a library that is used in a wide variety of applications it |
| 10 | +cannot fix all accessibility problems through its default configuration. |
| 11 | +Similarly, Blockly is not responsible for content on the rest of the page. |
| 12 | +This page lists our suggestions for accessibility best practices when using |
| 13 | +Blockly. |
| 14 | + |
| 15 | +## Keyboard shortcuts |
| 16 | + |
| 17 | +### Shortcut mapping |
| 18 | + |
| 19 | +Use Blockly's default keyboard shortcuts unless they conflict with |
| 20 | +preexisting shortcuts in your application. The Blockly team has worked with |
| 21 | +partners and the community to create a standard set of shortcuts that should |
| 22 | +work across a wide range of Blockly applications, and to encourage adoption. |
| 23 | +Using standard keyboard shortcuts allows your users to transfer their knowledge |
| 24 | +to and from other Blockly-based programming environments instead of learning a |
| 25 | +new set of shortcuts for each tool. |
| 26 | + |
| 27 | +### Multi-key shortcuts |
| 28 | + |
| 29 | +Blockly uses single-key shortcuts to support young users without strong |
| 30 | +keyboarding skills, older users with dexterity impairments, and usage across a |
| 31 | +wide range of browser/OS combinations. |
| 32 | + |
| 33 | +Advanced operations and standard actions such as copy and paste require users to |
| 34 | +press multiple keys at once. If a user cannot press multiple keys at the same |
| 35 | +time they should use the |
| 36 | +[sticky keys](https://en.wikipedia.org/wiki/Sticky_keys) setting in their |
| 37 | +operating system. |
| 38 | + |
| 39 | +### Teaching shortcuts |
| 40 | + |
| 41 | +Provide an interactive tutorial to introduce users to |
| 42 | +[basic keyboard navigation](/guides/configure/web/keyboard-nav#basic-operation). |
| 43 | +Start users off with only basic operations to reduce cognitive load. At the end |
| 44 | +of the tutorial, tell users where to look for additional help. |
| 45 | + |
| 46 | +Blockly's keyboard shortcuts are intended to be useful for all users, not only |
| 47 | +those with disabilities. Provide information about basic shortcuts in your |
| 48 | +documentation and instructions for all users. If you provide professional |
| 49 | +development resources, explicitly train teachers on keyboard shortcuts. |
| 50 | + |
| 51 | +### Shortcut help |
| 52 | + |
| 53 | +Make it easy for users to look up shortcuts on their own. To support a wide |
| 54 | +variety of computers and users, the list of keyboard shortcuts should be |
| 55 | +available within the Blockly workspace, as a separate web page, and as a |
| 56 | +printable resource. |
| 57 | + |
| 58 | +(June 2026): The Blockly team plans to release a plugin that displays the |
| 59 | +default keyboard shortcuts. If you have additional keyboard shortcuts in Blockly |
| 60 | +or on your page, you must update your shortcut list accordingly. |
| 61 | + |
| 62 | +## Vocabulary |
| 63 | + |
| 64 | +When working with users with visual impairments we recommend that you use |
| 65 | +tangible resources to introduce vocabulary. The |
| 66 | +[micro:bit documentation](https://microbit.org/accessibility/visual-impairment/#start-with-cut-out-cards) |
| 67 | +provides good examples. |
| 68 | + |
| 69 | +## Zoom |
| 70 | + |
| 71 | +Enable [resizing up to 200%](https://www.w3.org/WAI/WCAG22/Understanding/resize-text) |
| 72 | +through Blockly's [zoom controls](/guides/configure/web/zoom). |
| 73 | + |
| 74 | +## Colours |
| 75 | + |
| 76 | +Check your colours against [WCAG contrast standards](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum). |
| 77 | +If you cannot meet the standards with your default colours and cannot change |
| 78 | +colours due to published resources, use [themes](/guides/configure/web/appearance/themes) |
| 79 | +to provide colorblind-friendly modes and high-contrast mode. |
| 80 | + |
| 81 | +It may also be appropriate to provide a dark mode for your application. You can |
| 82 | +use themes to change Blockly's colours, but those changes should be synced with |
| 83 | +settings for the rest of your application. |
| 84 | + |
| 85 | +If you have an account system, save this information in user preferences. |
| 86 | + |
| 87 | +## Search |
| 88 | + |
| 89 | +Provide workspace search and toolbox search to help users jump to blocks. |
| 90 | +Linear traversal of a workspace or toolbox can be slow and tiring. |
| 91 | + |
| 92 | +(June 2026): The Blockly team will update the published toolbox search and |
| 93 | +workspace search plugins to work with v13. You may need custom implementations |
| 94 | +to fit your application. |
| 95 | + |
| 96 | +## Skip links |
| 97 | + |
| 98 | +Provide a [link that jumps directly to the Blockly workspace](https://www.w3.org/WAI/WCAG22/Techniques/general/G1) |
| 99 | +on each page. |
| 100 | + |
| 101 | +Provide an "area menu" that allows users to quickly jump between regions of the |
| 102 | +page (e.g. the block editor and the runtime area). See the "navigating between |
| 103 | +areas" section of the [Microsoft MakeCode accessibility page](https://makecode.com/accessibility) |
| 104 | +for an example implementation. |
| 105 | + |
| 106 | +## Clean up and reflow |
| 107 | + |
| 108 | +You may choose to force blocks into a single vertical stack, if appropriate for |
| 109 | +your application. You can do this by automatically reflowing the blocks after |
| 110 | +each drag by calling `workspace.cleanUp()`. |
| 111 | + |
| 112 | +Blockly does not need to meet the |
| 113 | +[WCAG Reflow criterion](https://www.w3.org/WAI/WCAG21/Understanding/reflow) |
| 114 | +because there is an exception for "content requiring two-dimensional layout". |
| 115 | + |
| 116 | +Consider carefully when making this choice. The intent of the criterion is to |
| 117 | +"let users enlarge text and other related content without having to scroll in |
| 118 | +two dimensions to read". However, in some Blockly applications users explicitly |
| 119 | +use the two-dimensional layout to structure their code. One example is |
| 120 | +[this Scratch project](https://scratch.mit.edu/projects/907456472/editor/) |
| 121 | +where the scripts are positioned to be visible at the same time. In this context |
| 122 | +a forced vertical layout would make it harder to read the code and require the |
| 123 | +user to hold more state in their mind when reading or editing. It would also |
| 124 | +increase the drag distance for most edits. |
| 125 | + |
| 126 | +An intermediate approach is to prompt users to use the |
| 127 | +[cleanup shortcut](/guides/configure/web/keyboard-nav#cleanup). |
| 128 | + |
| 129 | +## Screenreader optimizations |
| 130 | + |
| 131 | +Suggest that users turn on [screen reader optimizations](/guides/configure/web/screen-reader#screen-reader-optimizations) |
| 132 | +when they first navigate to the workspace using the keyboard. If you have an |
| 133 | +account system, save this information so users don't have to set it on every |
| 134 | +visit. |
| 135 | + |
| 136 | +## Documentation |
| 137 | + |
| 138 | +Publish an accessibility page on your product website. Include a statement on |
| 139 | +the compliance level of your product and links to all of your |
| 140 | +accessibility-related resources. You can use Blockly's Accessibility |
| 141 | +Conformance Report (ACR) as a portion of your compliance reporting. |
0 commit comments