Input and accessibility
One canvas and every way into it: mouse, pen, touch, wheel, trackpad and the keyboard alone, and what a screen reader is told about the drawing. Change how the canvas takes input in the toolbars, then try it - or put the pointer away, Tab into the canvas, press Enter and work the board with the keyboard. The panel beside it shows what assistive technology reads.
The keyboard
The canvas takes focus when it is drawn on, so the shortcuts are reachable for someone who just used a mouse or a pen. Stepping through elements and changing them (Enter to start, Tab, the arrow keys, R, Shift+H and Shift+V) is the select tool's work, so those keys act while it is the active tool; the others work whatever the tool. Ctrl means Command on macOS.
| Key | Action |
|---|---|
Ctrl+Z | Undo |
Ctrl+Shift+Z, Ctrl+Y | Redo |
Ctrl+A | Select everything on unlocked, visible layers |
Enter | Select the first element, which is how navigating without a pointer starts |
Tab, Shift+Tab | Step to the next or previous element or group, announcing each one |
Delete, Backspace | Delete the selection |
Escape | Cancel the gesture, then leave the group being worked inside, then clear the selection |
Arrow keys | Nudge the selection by one unit; with Shift, by ten |
Ctrl+arrow keys | Resize the selection; with Shift, in larger steps |
R, Shift+R | Rotate the selection by 15 degrees either way |
Shift+H, Shift+V | Flip the selection horizontally or vertically |
Ctrl+D | Duplicate the selection |
Ctrl+], Ctrl+[ | Bring the selection forward, send it backward; with Shift, to the front or the back |
Ctrl+G, Ctrl+Shift+G | Group the selection, ungroup it |
Ctrl+Shift+L | Lock the selection |
Ctrl+C, Ctrl+X, Ctrl+V | Copy, cut and paste, when EnableClipboard is on |
Enter, with the text tool | Open a text box in the middle of the view |
Enter, with a shape tool | Add the shape in the middle of the view, to move and resize with the select tool |
Ctrl+0 | Reset the zoom |
Ctrl+9 | Zoom to fit |
Ctrl+plus, Ctrl+minus | Zoom in, zoom out |
Delete, Backspace and the arrow keys are left to the page while nothing is selected, so a keyboard user can
still scroll past a focused canvas, and so are Ctrl+C, Ctrl+X, Ctrl+D and the bracket shortcuts, so copying text
beside the canvas keeps working. Keys typed into an input, a button or a link inside the canvas's
ChildContent are never intercepted. Keyboard input travels the same path as pointer input, so a
keystroke does not re-render the component. Focusable, on by default, is what puts the canvas in
the tab order at all; without focus there are no shortcuts.
Taking keys back
EnableKeyboardShortcuts="false" releases every key: the canvas acts on none of them, and the browser
layer stops preventing their default behaviour as well. To take back only some, list them in
DisabledShortcuts - as "Leave Delete and R to the page" does above: Delete no longer deletes and R
no longer rotates, while everything else keeps working, Backspace included, because each chord is its own. A
disabled chord reaches neither the tool nor the canvas, and its default comes back (Ctrl+D, say, bookmarks the
page again).
<BinkCanvas DisabledShortcuts="@(new[] { "Delete", "R", "Ctrl+Shift+]" })" /> BinkShortcut.Normalize("Cmd + Shift + Z"); // "Ctrl+Shift+Z": how a chord is read
Chords are modifiers and a key joined with +. Cmd, Meta and
Control read as Ctrl, Option as Alt, letters can be written in either case, and a chord
written with the unshifted key also matches the character the browser reports for it. To move a command to
another key, disable its chord, handle the new key in the page and call the canvas method behind it, such as
DuplicateSelection or Undo. Enter and Escape in the inline text editor are how the editor
works, so they cannot be disabled.
Scrolling, drawing and zooming
Whether a finger drags the drawing or scrolls the page is the one decision a touch screen forces, and no setting
gets both, so the canvas asks. With EnableTouchGestures off, the default, the canvas sets
touch-action: pan-x pan-y: a finger scrolls the page, a pen still draws, and a field embedded in a long
form never traps it. On, the canvas owns every touch: one finger draws, and a second takes the gesture over -
cancelling the stroke under way - to pan and pinch-zoom until the last finger lifts, whatever the tool.
RejectTouchWhilePen ignores touches while a pen is down, and a touch makes handles and elements
easier to hit (BinkSelectTool.TouchTargetScale), close to the 24 pixel target WCAG 2.5.8 asks for.
| WheelMode | Wheel | Ctrl+wheel, trackpad pinch | Shift+wheel |
|---|---|---|---|
None (default) | Scrolls the page | Browser zoom | Scrolls the page |
PanAndZoom | Pans | Zooms around the pointer | Pans sideways |
Zoom | Zooms around the pointer | Zooms around the pointer | Pans |
<BinkCanvas EnableTouchGestures="true" RejectTouchWhilePen="true" WheelMode="BinkWheelMode.PanAndZoom" MinZoom="0.5f" MaxZoom="4f" />
PanAndZoom is the convention of design tools, Zoom that of maps, and the default leaves the
wheel to the page. MinZoom and MaxZoom bound every way of zooming - the wheel, a pinch,
the keyboard, ZoomBy and ZoomToFit. Panning and zooming change only the view, so they
are never an undo step and never touch the document.
What a screen reader is told
A canvas is pixels, and no amount of ARIA lets a screen reader describe handwriting. What the canvas does
provide is real: it is a focusable element with role="application", a "drawing canvas" role
description and the name given in AriaLabel; it is described by a live summary of what the drawing
contains, built from each element's Description or, without one, a structural summary such as
"Stroke, 142 points, pen brush"; and it announces what happened - how many elements a marquee selected, how many
strokes an erase removed - through a polite live region, at most once per frame. The panel above shows those
descriptions.
<BinkCanvas AriaLabel="Signature for the tenancy agreement" /> _document.AddElement(new BinkLineShape(a, b) { EndArrow = true, Description = "Arrow from Inbox to In progress" }); _canvas.Announce("Signature captured.");
What the application must still do is give elements meaningful descriptions, and offer a route to any
information that exists only as a drawing. Exported SVG carries the same descriptions as title
elements when IncludeElementDescriptions is set. Under forced colours the canvas keeps its own
colours, because a drawing repainted in the system palette is no longer the user's drawing; there are no
animations to reduce.
What WCAG asks of a drawing surface
Freehand drawing is a path-based gesture, which 2.5.1 Pointer Gestures exempts where the path itself is
essential: nobody can draw a signature with arrow keys. Everything around the drawing is not exempt, which is
why tools, colours, undo, layers and export have to be ordinary controls. The toolbars on these pages are real
buttons and inputs with aria-pressed, labels and role="toolbar", operable without the
canvas being involved at all - so build yours the same way, beside the canvas rather than inside it. Under 1.1.1
Non-text Content, a drawing needs a text alternative, and Description is how one is given.
What this device offers
Ready hands over what the browser supports. Feature detection only says what the browser could do,
so the canvas's Capabilities also gains ObservedPen, ObservedTouch,
ObservedPressure and ObservedTilt as input actually arrives - the reliable way to know a
stylus is in use. Draw on the canvas and watch them change.