Keyboard
Where keys come from#
Each map adapter listens to keydown on the document, not on the map, so keys work without
clicking into the map first. Keys typed into an input field, a text area, a select box or a
contenteditable element are ignored. Two editors on the same page both receive every key.
The adapters report key presses only. Releasing Alt or Shift takes effect with the next pointer movement.
A key goes to the active mode first. The toolbar then sees it through the keyunhandled event —
none of the built-in modes consumes a key, so a tool shortcut would in principle work in every
tool. The toolbar itself holds it back, though, as long as the active mode reports an unfinished
gesture (Mode.laeuftEtwas()) — points collected toward a ring, a drag in progress, but also the
first click of a two-click tool (split, union) or an open input in text: the shortcut does
nothing and the gesture continues. Escape still aborts it as before, and clicking a toolbar
button switches regardless of laeuftEtwas(), exactly as a direct editor.setMode() call does.
Tool shortcuts#
With defaultToolbarEntries(); case-insensitive, only without Ctrl, Alt and Cmd:
| Key | Tool | Key | Tool |
|---|---|---|---|
| P | draw (polygon) |
U | union |
| R | draw-rectangle |
E | removal |
| C | draw-circle |
V | transform |
| L | draw-line |
I | simplify |
| N | draw-point |
G | regularize |
| M | draw-marker |
F | freehand |
| T | text |
1 | stamp-triangle |
| A | edit |
2 | stamp-star |
| X | split |
S | cut |
| K | copy |
D | difference |
| Q | lasso |
vectorstream Pro adds two tools: cut-circle (H) and difference-circle (J), see the Pro modes.
Your own tool list sets its own keys; see Toolbar.
Keys inside the tools#
| Key | Where | Effect |
|---|---|---|
| Enter | draw |
Closes the polygon (at least three vertices). |
draw-line |
Finishes the line (at least two vertices). | |
cut, difference |
Closes the ring and cuts (at least three vertices). | |
simplify, regularize |
Applies the tool to the selected faces. | |
| Backspace | draw, draw-line, cut, difference |
Removes the last vertex (a traced section as a whole). |
| Delete, Backspace | removal |
Removes the selected faces. |
| Escape | draw, draw-line, cut, difference |
Discards the unfinished drawing. |
draw-rectangle, draw-circle, freehand, stamps, copy, lasso, edit, transform, text |
Aborts the current drag. | |
split, union |
Abandons the first click (union also clears the selection). |
|
removal, simplify, regularize |
Clears the selection. | |
| pasting with the pointer | Cancels the paste. | |
| Alt (held) | all tools | Suspends snapping: the point lands exactly at the pointer. |
edit |
Alt+click on a vertex removes it; Alt+drag on an edge moves only that edge. | |
| Shift (held) | transform |
Shift+click adds to or removes from the selection; while scaling, width and height change independently. |
draw-circle |
Draws an ellipse instead of a circle. | |
edit |
While dragging an edge, it follows the pointer freely instead of moving perpendicular. | |
cut, difference |
Traces along existing boundaries between two snapped clicks. |
In the text tool, Enter and Escape in the input field belong to your field; see
Labels and attributes.
What the library leaves to you#
The editor binds no system shortcuts — no undo, redo, copy or paste keys. A mode sees keys first, and a system shortcut should not depend on which tool happens to be active. Bind them in your application:
- Undo and redo:
editor.undo(),editor.redo()— a complete example is on Undo and redo. - Copy and paste shapes:
editor.kopieren(),editor.einfuegen()oreditor.einfuegenMitZeiger(); copy and apply dimensions:editor.massKopieren(),editor.massEinfuegen(). See Modes.
The application in this repository (app/) binds Ctrl/Cmd+Z (undo), Shift+Ctrl/Cmd+Z (redo),
Ctrl/Cmd+C (copy shape), Shift+Ctrl/Cmd+C (copy dimensions) and Ctrl/Cmd+V (paste).