Skip to content

Commit 1e67022

Browse files
authored
[SR] Allow using control + shift + arrow keys for NVDA (#2257)
## Summary: NVDA takes control of inputs in its default mode, so users can't use just the arrow keys to move the interactive elements on the graph. We want to allow using modifier key + control + shift + arrow keys to move interactive elements on the graph. Note: This already works with the modifier key + shift + arrow keys (no control), but holding down shift makes it so that the amount the element moves is 4x more than without shift. Note 2: When using NVDA, you can get the same keyboard experience as not using a screen reader (i.e. move the points with arrow keys only) if you go into focus mode (NVDA key + space bar). Implemented: - Added support for the control key press - stops shift from increasing the move difference if control is held down - Added "modifier key + control + shift +" to the instruction strings Issue: https://khanacademy.atlassian.net/browse/LEMS-2874 ## Test plan: `yarn jest packages/perseus/src/widgets/interactive-graphs/interactive-graph.test.tsx` Storybook http://localhost:6006/?path=/docs/perseuseditor-widgets-interactive-graph--docs Author: nishasy Reviewers: SonicScrewdriver, mark-fitzgerald, catandthemachines Required Reviewers: Approved By: SonicScrewdriver Checks: ✅ 8 checks were successful Pull Request URL: #2257
1 parent 7be7a42 commit 1e67022

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

.changeset/four-bulldogs-cheat.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/perseus": patch
3+
---
4+
5+
[SR] Allow using control + shift + arrow keys for NVDA

packages/perseus/src/strings.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,9 @@ export const strings = {
690690
// been finalized. Remove this comment after the tickets have been
691691
// created.
692692
srGraphInstructions:
693-
"Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use the Arrow keys to move it.",
693+
"Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use Control + Shift + Arrows to move it.",
694694
srUnlimitedGraphInstructions:
695-
"Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use the Arrow keys to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.",
695+
"Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use Control + Shift + Arrows to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.",
696696
xAxis: "X-axis",
697697
yAxis: "Y-axis",
698698
srPointAtCoordinates: "Point %(num)s at %(x)s comma %(y)s.",
@@ -970,9 +970,9 @@ export const mockStrings: PerseusStrings = {
970970

971971
// The following strings are used for interactive graph SR descriptions.
972972
srGraphInstructions:
973-
"Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use the Arrow keys to move it.",
973+
"Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use Control + Shift + Arrows to move it.",
974974
srUnlimitedGraphInstructions:
975-
"Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use the Arrow keys to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.",
975+
"Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use Control + Shift + Arrows to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.",
976976
xAxis: "X-axis",
977977
yAxis: "Y-axis",
978978
graphKeyboardPrompt: "Press Shift + Enter to interact with the graph",

packages/perseus/src/widgets/interactive-graphs/__snapshots__/interactive-graph.test.tsx.snap

+8-8
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
11181118
id="instructions-:r2:"
11191119
tabindex="-1"
11201120
>
1121-
Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use the Arrow keys to move it.
1121+
Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use Control + Shift + Arrows to move it.
11221122
</div>
11231123
<div
11241124
class="default_xu2jcg-o_O-inlineStyles_16155wj"
@@ -1559,7 +1559,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
15591559
id="instructions-:ra:"
15601560
tabindex="-1"
15611561
>
1562-
Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use the Arrow keys to move it.
1562+
Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use Control + Shift + Arrows to move it.
15631563
</div>
15641564
<div
15651565
class="default_xu2jcg-o_O-inlineStyles_16155wj"
@@ -2006,7 +2006,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
20062006
id="instructions-:rh:"
20072007
tabindex="-1"
20082008
>
2009-
Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use the Arrow keys to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.
2009+
Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use Control + Shift + Arrows to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.
20102010
</div>
20112011
<div
20122012
class="default_xu2jcg-o_O-inlineStyles_16155wj"
@@ -2258,7 +2258,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
22582258
id="instructions-:rm:"
22592259
tabindex="-1"
22602260
>
2261-
Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use the Arrow keys to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.
2261+
Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use Control + Shift + Arrows to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.
22622262
</div>
22632263
<div
22642264
class="default_xu2jcg-o_O-inlineStyles_16155wj"
@@ -2502,7 +2502,7 @@ exports[`Interactive Graph question Should render predictably: first render 1`]
25022502
id="instructions-:r2:"
25032503
tabindex="-1"
25042504
>
2505-
Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use the Arrow keys to move it.
2505+
Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use Control + Shift + Arrows to move it.
25062506
</div>
25072507
<div
25082508
class="default_xu2jcg-o_O-inlineStyles_16155wj"
@@ -2943,7 +2943,7 @@ exports[`Interactive Graph question Should render predictably: first render 2`]
29432943
id="instructions-:ra:"
29442944
tabindex="-1"
29452945
>
2946-
Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use the Arrow keys to move it.
2946+
Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use Control + Shift + Arrows to move it.
29472947
</div>
29482948
<div
29492949
class="default_xu2jcg-o_O-inlineStyles_16155wj"
@@ -3390,7 +3390,7 @@ exports[`Interactive Graph question Should render predictably: first render 3`]
33903390
id="instructions-:rh:"
33913391
tabindex="-1"
33923392
>
3393-
Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use the Arrow keys to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.
3393+
Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use Control + Shift + Arrows to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.
33943394
</div>
33953395
<div
33963396
class="default_xu2jcg-o_O-inlineStyles_16155wj"
@@ -3642,7 +3642,7 @@ exports[`Interactive Graph question Should render predictably: first render 4`]
36423642
id="instructions-:rm:"
36433643
tabindex="-1"
36443644
>
3645-
Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use the Arrow keys to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.
3645+
Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use Control + Shift + Arrows to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.
36463646
</div>
36473647
<div
36483648
class="default_xu2jcg-o_O-inlineStyles_16155wj"

packages/perseus/src/widgets/interactive-graphs/graphs/use-draggable.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export function useDraggable(args: Params): DragState {
104104
const {
105105
direction: yDownDirection,
106106
altKey,
107+
ctrlKey,
107108
metaKey,
108109
shiftKey,
109110
} = state;
@@ -119,7 +120,7 @@ export function useDraggable(args: Params): DragState {
119120
if (altKey || metaKey) {
120121
divisions = 200;
121122
}
122-
if (shiftKey) {
123+
if (shiftKey && !ctrlKey) {
123124
divisions = 10;
124125
}
125126

packages/perseus/src/widgets/interactive-graphs/interactive-graph.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ const updateWidgetState = (renderer: Renderer, widgetId: string, update) => {
7777
renderer.restoreSerializedState(state);
7878
};
7979
const commonInstructions =
80-
"Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use the Arrow keys to move it.";
80+
"Use the Tab key to move through the interactive elements in the graph. When an interactive element has focus, use Control + Shift + Arrows to move it.";
8181
const unlimitedInstructions =
82-
"Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use the Arrow keys to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.";
82+
"Press Shift + Enter to interact with the graph. Use the Tab key to move through the interactive elements in the graph and access the graph Action Bar. When an interactive element has focus, use Control + Shift + Arrows to move it or use the Delete key to remove it from the graph. Use the buttons in the Action Bar to add or adjust elements within the graph.";
8383

8484
const blankOptions: APIOptions = Object.freeze(ApiOptions.defaults);
8585

0 commit comments

Comments
 (0)