improve keyboard and screen reader access to seed words, dark theme buttons, text areas, keystore sources and the cosigners slider
What changed, and why it matters
This commit improves keyboard navigation and screen-reader accessibility in the Sparrow Wallet desktop app. It makes Tab key move focus out of text boxes that hold keys, addresses, or scripts; fixes how screen readers describe seed-word fields and the multisig cosigner slider; and ensures hidden form fields are not reachable by keyboard or assistive tools. It is an accessibility/usability fix, not a cryptographic or network security patch.
No security response required. Treat as a normal accessibility/usability improvement. Reviewers may optionally verify that focus traversal behaves correctly with assistive technologies and that removing button focus-traversability in the dark theme does not regress keyboard navigation elsewhere.
Security signals we found
Accessibility hardening: prevents hidden/overlayed form fields from being reachable by keyboard or screen reader
UI/UX fix: Tab key no longer trapped in sensitive text areas, reducing user error and improving keyboard-only operation
No cryptographic, network, or privilege changes observed
No input validation, parsing, or secret-handling logic changes observed
Evidence from the diff
The patch adds a shared helper AppServices.moveFocusOnTab(Node) that intercepts Tab in text/code areas so focus traverses instead of inserting a tab character. It applies this to descriptor, script, selectable code, transaction hex, message signature, private-key sweep, generic dialog, and xprv text areas. It also adds a new CosignersSlider subclass of ControlsFX RangeSlider to expose the low/high thumbs to JavaFX accessibility with proper role, value, name, and keyboard handling. MnemonicKeystorePane now labels each seed-word field via its label instead of overriding the field’s accessible text. KeystoreController binds the keystore form’s visibility to the inverse of the source-selection overlay so underlying fields are not in the keyboard/screen-reader tab order. A dark-theme CSS rule that made buttons non-focus-traversable is removed.
Changed components
AppServices.javaCosignersSlider.javaDescriptorArea.javaMessageSignDialog.javaMnemonicKeystorePane.javaPrivateKeySweepDialog.javaScriptArea.javaSelectableCodeArea.javaTextAreaDialog.javaTransactionHexArea.javaXprvKeystoreImportPane.javaKeystoreController.javadarktheme.csswallet/settings.fxmlInspect captured patch +165 / −7
### src/main/java/com/sparrowwallet/sparrow/AppServices.java
@@ -45,6 +45,7 @@
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
+import javafx.scene.TraversalDirection;
import javafx.scene.control.*;
import javafx.scene.control.Dialog;
import javafx.scene.image.Image;
@@ -709,6 +710,16 @@ public static void onEscapePressed(Scene scene, Runnable runnable) {
});
}
+ //Text areas holding keys, addresses or scripts never need a tab character, so Tab moves focus on rather than trapping keyboard users
+ public static void moveFocusOnTab(Node node) {
+ node.addEventFilter(javafx.scene.input.KeyEvent.KEY_PRESSED, event -> {
+ if(event.getCode() == KeyCode.TAB && !event.isShortcutDown() && !event.isControlDown() && !event.isAltDown()) {
+ node.requestFocusTraversal(event.isShiftDown() ? TraversalDirection.PREVIOUS : TraversalDirection.NEXT);
+ event.consume();
+ }
+ });
+ }
+
public Map<Wallet, Storage> getOpenWallets() {
Map<Wallet, Storage> openWallets = new LinkedHashMap<>();
for(List<WalletTabData> walletTabDataList : walletWindows.values()) {
### src/main/java/com/sparrowwallet/sparrow/control/CosignersSlider.java
@@ -0,0 +1,120 @@
+package com.sparrowwallet.sparrow.control;
+
+import javafx.application.Platform;
+import javafx.beans.InvalidationListener;
+import javafx.collections.FXCollections;
+import javafx.event.EventHandler;
+import javafx.scene.AccessibleAction;
+import javafx.scene.AccessibleAttribute;
+import javafx.scene.AccessibleRole;
+import javafx.scene.Node;
+import javafx.scene.TraversalDirection;
+import javafx.scene.input.KeyCode;
+import javafx.scene.input.KeyEvent;
+import org.controlsfx.control.RangeSlider;
+
+/**
+ * Range slider for the multisig threshold (low thumb) and number of cosigners (high thumb), exposed to screen readers as a slider
+ * for whichever thumb is selected. The thumbs are not controls, so without this the slider has no role, value or name.
+ */
+public class CosignersSlider extends RangeSlider {
+ private final InvalidationListener accessibleValueListener = _ -> updateAccessibleValue();
+ private final EventHandler<KeyEvent> sceneKeyPressedFilter = event -> shiftTabPressed = event.getCode() == KeyCode.TAB && event.isShiftDown();
+ private final EventHandler<KeyEvent> sceneKeyReleasedFilter = _ -> shiftTabPressed = false;
+ private boolean shiftTabPressed;
+ private Node highThumb;
+
+ public CosignersSlider() {
+ setAccessibleRole(AccessibleRole.SLIDER);
+ lowValueProperty().addListener(accessibleValueListener);
+ highValueProperty().addListener(accessibleValueListener);
+ skinProperty().addListener((_, _, _) -> {
+ if(highThumb != null) {
+ highThumb.focusedProperty().removeListener(accessibleValueListener);
+ }
+ //Tab moves between the thumbs by setting their focused state, while the slider itself keeps the scene focus.
+ //A thumb taking the scene focus is a further, unnamed Tab stop.
+ Node lowThumb = lookup(".low-thumb");
+ if(lowThumb != null) {
+ lowThumb.setFocusTraversable(false);
+ }
+ highThumb = lookup(".high-thumb");
+ if(highThumb != null) {
+ highThumb.setFocusTraversable(false);
+ highThumb.focusedProperty().addListener(accessibleValueListener);
+ }
+ });
+ //Leaving the slider by Tab uses scene traversal: the skin otherwise focuses the next sibling or parent, an unnamed Tab stop
+ addEventFilter(KeyEvent.KEY_PRESSED, event -> {
+ boolean leaving = event.isShiftDown() ? !isHighThumbSelected() : isHighThumbSelected();
+ if(event.getCode() == KeyCode.TAB && !event.isShortcutDown() && !event.isControlDown() && !event.isAltDown() && leaving) {
+ requestFocusTraversal(event.isShiftDown() ? TraversalDirection.PREVIOUS : TraversalDirection.NEXT);
+ event.consume();
+ }
+ });
+ //The skin selects the low thumb whenever the slider gains focus, so arriving backwards selects the high thumb with its own Tab handling.
+ //Focus moves on the key press, so the Shift-Tab is only noted until its release.
+ sceneProperty().addListener((_, oldScene, newScene) -> {
+ if(oldScene != null) {
+ oldScene.removeEventFilter(KeyEvent.KEY_PRESSED, sceneKeyPressedFilter);
+ oldScene.removeEventFilter(KeyEvent.KEY_RELEASED, sceneKeyReleasedFilter);
+ }
+ if(newScene != null) {
+ newScene.addEventFilter(KeyEvent.KEY_PRESSED, sceneKeyPressedFilter);
+ newScene.addEventFilter(KeyEvent.KEY_RELEASED, sceneKeyReleasedFilter);
+ }
+ });
+ focusedProperty().addListener((_, _, focused) -> {
+ if(focused && shiftTabPressed) {
+ Platform.runLater(() -> {
+ if(isFocused() && !isHighThumbSelected()) {
+ fireEvent(new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.TAB, false, false, false, false));
+ }
+ });
+ }
+ });
+ updateAccessibleValue();
+ }
+
+ private boolean isHighThumbSelected() {
+ return highThumb != null && highThumb.isFocused();
+ }
+
+ private void updateAccessibleValue() {
+ //Screen readers announce a slider's value as a percentage of its range, so the counts are given in the name
+ int required = (int)getLowValue();
+ int cosigners = (int)getHighValue();
+ setAccessibleText(isHighThumbSelected() ? cosigners + (cosigners == 1 ? " cosigner, " : " cosigners, ") + required + " required to sign" : required + " of " + cosigners + " required to sign");
+ notifyAccessibleAttributeChanged(AccessibleAttribute.VALUE);
+ }
+
+ @Override
+ public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
+ return switch(attribute) {
+ case VALUE -> isHighThumbSelected() ? getHighValue() : getLowValue();
+ case MIN_VALUE -> getMin();
+ case MAX_VALUE -> getMax();
+ case ORIENTATION -> getOrientation();
+ //The tick labels would otherwise be read as separate numbers
+ case CHILDREN -> FXCollections.emptyObservableList();
+ default -> super.queryAccessibleAttribute(attribute, parameters);
+ };
+ }
+
+ @Override
+ public void executeAccessibleAction(AccessibleAction action, Object... parameters) {
+ switch(action) {
+ case INCREMENT -> adjustSelected(getBlockIncrement());
+ case DECREMENT -> adjustSelected(-getBlockIncrement());
+ default -> super.executeAccessibleAction(action, parameters);
+ }
+ }
+
+ private void adjustSelected(double delta) {
+ if(isHighThumbSelected()) {
+ adjustHighValue(getHighValue() + delta);
+ } else {
+ adjustLowValue(getLowValue() + delta);
+ }
+ }
+}
### src/main/java/com/sparrowwallet/sparrow/control/DescriptorArea.java
@@ -6,6 +6,7 @@
import com.sparrowwallet.drongo.protocol.ScriptType;
import com.sparrowwallet.drongo.wallet.Keystore;
import com.sparrowwallet.drongo.wallet.Wallet;
+import com.sparrowwallet.sparrow.AppServices;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.input.Clipboard;
@@ -20,6 +21,10 @@
public class DescriptorArea extends CodeArea {
private Wallet wallet;
+ public DescriptorArea() {
+ AppServices.moveFocusOnTab(this);
+ }
+
public void setWallet(Wallet wallet) {
clear();
this.wallet = wallet;
### src/main/java/com/sparrowwallet/sparrow/control/MessageSignDialog.java
@@ -157,6 +157,7 @@ public MessageSignDialog(Wallet wallet, WalletNode walletNode, String title, Str
Field signatureField = new Field();
signatureField.setText("Signature:");
signature = new TextArea();
+ AppServices.moveFocusOnTab(signature);
signature.getStyleClass().add("id");
signature.setPrefRowCount(4);
signature.setStyle("-fx-pref-height: 80px");
### src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystorePane.java
@@ -321,7 +321,9 @@ public void paste() {
}
};
wordField.setMaxWidth(100);
- wordField.setAccessibleText("Word " + (wordNumber + 1));
+ //Named through its label: accessible text on a text field replaces the word as the field's value
+ label.setAccessibleText("Word " + (wordNumber + 1));
+ label.setLabelFor(wordField);
TextFormatter<?> formatter = new TextFormatter<>((TextFormatter.Change change) -> {
String text = change.getText();
// if text was added, fix the text to fit the requirements
### src/main/java/com/sparrowwallet/sparrow/control/PrivateKeySweepDialog.java
@@ -88,6 +88,7 @@ public PrivateKeySweepDialog(Wallet wallet) {
Field keyField = new Field();
keyField.setText("Private Key:");
key = new TextArea();
+ AppServices.moveFocusOnTab(key);
key.setWrapText(true);
key.setPromptText("Wallet Import Format (WIF) or BIP38 encrypted key");
key.setPrefRowCount(2);
### src/main/java/com/sparrowwallet/sparrow/control/ScriptArea.java
@@ -3,6 +3,7 @@
import com.sparrowwallet.drongo.protocol.Script;
import com.sparrowwallet.drongo.protocol.ScriptChunk;
import com.sparrowwallet.drongo.protocol.ScriptOpCodes;
+import com.sparrowwallet.sparrow.AppServices;
import javafx.geometry.Pos;
import org.controlsfx.control.decoration.Decorator;
import org.controlsfx.control.decoration.GraphicDecoration;
@@ -13,6 +14,10 @@
public class ScriptArea extends CodeArea {
private Script script;
+ public ScriptArea() {
+ AppServices.moveFocusOnTab(this);
+ }
+
public void appendScript(Script script) {
appendScript(script, null, null);
}
### src/main/java/com/sparrowwallet/sparrow/control/SelectableCodeArea.java
@@ -1,5 +1,6 @@
package com.sparrowwallet.sparrow.control;
+import com.sparrowwallet.sparrow.AppServices;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.input.Clipboard;
@@ -9,6 +10,7 @@
public class SelectableCodeArea extends CodeArea {
public SelectableCodeArea() {
super();
+ AppServices.moveFocusOnTab(this);
ContextMenu contextMenu = new ContextMenu();
MenuItem copy = new MenuItem("Copy");
### src/main/java/com/sparrowwallet/sparrow/control/TextAreaDialog.java
@@ -48,6 +48,7 @@ public TextAreaDialog(@NamedArg("defaultValue") String defaultValue, @NamedArg("
HBox hbox = new HBox();
this.textArea = new TextArea(defaultValue);
+ AppServices.moveFocusOnTab(textArea);
this.textArea.setMaxWidth(Double.MAX_VALUE);
this.textArea.setWrapText(true);
this.textArea.getStyleClass().add("fixed-width");
### src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java
@@ -2,6 +2,7 @@
import com.sparrowwallet.drongo.Utils;
import com.sparrowwallet.drongo.protocol.*;
+import com.sparrowwallet.sparrow.AppServices;
import javafx.application.Platform;
import javafx.geometry.Point2D;
import javafx.scene.control.ContextMenu;
@@ -31,6 +32,7 @@ public class TransactionHexArea extends CodeArea {
public TransactionHexArea() {
super();
+ AppServices.moveFocusOnTab(this);
addPopupHandler();
}
### src/main/java/com/sparrowwallet/sparrow/control/XprvKeystoreImportPane.java
@@ -8,6 +8,7 @@
import com.sparrowwallet.drongo.wallet.MnemonicException;
import com.sparrowwallet.drongo.wallet.Wallet;
import com.sparrowwallet.drongo.wallet.WalletModel;
+import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.event.KeystoreImportEvent;
import com.sparrowwallet.sparrow.io.ImportException;
@@ -128,6 +129,7 @@ private void importKeystore(List<ChildNumber> derivation) {
private Node getXprvEntry(boolean displayOnly) {
TextArea xprvField = new TextArea();
+ AppServices.moveFocusOnTab(xprvField);
xprvField.setPrefRowCount(2);
xprvField.setWrapText(true);
xprvField.getStyleClass().add("fixed-width");
### src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java
@@ -35,6 +35,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tornadofx.control.Field;
+import tornadofx.control.Form;
import javax.smartcardio.CardException;
import java.net.URL;
@@ -48,6 +49,9 @@ public class KeystoreController extends WalletFormController implements Initiali
private Keystore keystore;
+ @FXML
+ private Form keystoreForm;
+
@FXML
private StackPane selectSourcePane;
@@ -121,6 +125,8 @@ public class KeystoreController extends WalletFormController implements Initiali
@Override
public void initialize(URL location, ResourceBundle resources) {
EventManager.get().register(this);
+ AppServices.moveFocusOnTab(xpub);
+ AppServices.moveFocusOnTab(spScan);
}
public void setKeystore(WalletForm walletForm, Keystore keystore) {
@@ -133,6 +139,8 @@ public void initializeView() {
Platform.runLater(this::setupValidation);
selectSourcePane.managedProperty().bind(selectSourcePane.visibleProperty());
+ //The source choice covers the keystore form, so its fields must not be reachable by keyboard or screen reader underneath
+ keystoreForm.visibleProperty().bind(selectSourcePane.visibleProperty().not());
if(keystore.isValid() || keystore.getExtendedPublicKey() != null) {
selectSourcePane.setVisible(false);
} else if(!getWalletForm().getWallet().isMasterWallet() && keystore.getKeyDerivation() != null) {
@@ -307,6 +315,7 @@ public void selectSource(ActionEvent event) {
derivation.setText(getWalletForm().getWallet().getPolicyType() == PolicyType.SINGLE_SP ? KeyDerivation.writePath(KeyDerivation.getBip352Derivation(0))
: getWalletForm().getWallet().getScriptType().getDefaultDerivationPath());
selectSourcePane.setVisible(false);
+ label.requestFocus();
}
}
@@ -447,6 +456,7 @@ private void launchImportDialog(KeystoreSource initialSource) {
Optional<Keystore> result = dlg.showAndWait();
if(result.isPresent()) {
selectSourcePane.setVisible(false);
+ label.requestFocus();
Keystore importedKeystore = result.get();
if(keystore.getSource() == KeystoreSource.SW_SEED && importedKeystore.getSource() != KeystoreSource.SW_SEED) {
### src/main/resources/com/sparrowwallet/sparrow/darktheme.css
@@ -16,10 +16,6 @@
-fx-prompt-text-fill: gray;
}
-.button{
- -fx-focus-traversable: false;
-}
-
.button:hover{
-fx-text-fill: white;
}
### src/main/resources/com/sparrowwallet/sparrow/wallet/settings.fxml
@@ -5,7 +5,7 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import tornadofx.control.*?>
-<?import org.controlsfx.control.RangeSlider?>
+<?import com.sparrowwallet.sparrow.control.CosignersSlider?>
<?import com.sparrowwallet.sparrow.control.CopyableLabel?>
<?import com.sparrowwallet.drongo.policy.PolicyType?>
<?import com.sparrowwallet.drongo.protocol.ScriptType?>
@@ -65,7 +65,7 @@
<Form GridPane.columnIndex="1" GridPane.rowIndex="0">
<Fieldset inputGrow="SOMETIMES" text="" fx:id="multisigFieldset">
<Field text="Cosigners:">
- <RangeSlider fx:id="multisigControl" showTickMarks="true" showTickLabels="true" blockIncrement="1" min="1" max="9" highValue="3" lowValue="2" snapToTicks="true" majorTickUnit="1" minorTickCount="0" />
+ <CosignersSlider fx:id="multisigControl" showTickMarks="true" showTickLabels="true" blockIncrement="1" min="1" max="9" highValue="3" lowValue="2" snapToTicks="true" majorTickUnit="1" minorTickCount="0" />
</Field>
<Field text="M of N:">
<CopyableLabel fx:id="multisigLowLabel" />Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.