Selaa lähdekoodia

submit comma with enter

Bernadette Elena Hammerle 2 vuotta sitten
vanhempi
commit
2768df6dcb
2 muutettua tiedostoa jossa 7 lisäystä ja 1 poistoa
  1. 4 1
      src/Addition.js
  2. 3 0
      src/Subtraction.js

+ 4 - 1
src/Addition.js

@@ -18,7 +18,7 @@ function Addition() {
   const [resultsGrid, setResultsGrid] = useState([{id: 1, number: ""}]); // calculated result
   const [stepsGrid, setStepsGrid] = useState([{id: 1, step: ""}]); // one step for every digit
 
-  const [autoMoveComma, setAutoMoveComma] = useState(true); // move the comma automatically
+  const [autoMoveComma, setAutoMoveComma] = useState(false); // move the comma automatically
   const [allowStartOver, setAllowStartOver] = useState(true); // show steps and allow restart
 
   // focus the input field
@@ -139,6 +139,9 @@ function Addition() {
     }else if(pressedKey === 40){ // down
       let nextFocusId = Math.min(noId+1, numbers.length-1);
       document.getElementById("numbersTd" + nextFocusId).focus();
+
+    }else if(pressedKey === 13){ // enter
+      submitCommaMove();
     }
   };
 

+ 3 - 0
src/Subtraction.js

@@ -142,6 +142,9 @@ function Subtraction() {
     }else if(pressedKey === 40){ // down
       let nextFocusId = Math.min(noId+1, numbers.length-1);
       document.getElementById("numbersTd" + nextFocusId).focus();
+
+    }else if(pressedKey === 13){ // enter
+      submitCommaMove();
     }
   };