Skip to content

Commit

Permalink
Updating to using switch statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Gallant committed Apr 28, 2024
1 parent e2f3699 commit b940b88
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/Components/Sudoku Board/SudokuBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ const SudokuBoard = (props: SudokuBoardProps) => {
const handleKeyDown = (event: any) => {
const inputValue = event.nativeEvent.key;

console.log(inputValue);

switch (inputValue) {
case "u":
case "U":
Expand All @@ -460,6 +462,7 @@ const SudokuBoard = (props: SudokuBoardProps) => {
case "n":
case "N":
toggleNoteMode();
return;
default:
break;
}
Expand All @@ -468,12 +471,14 @@ const SudokuBoard = (props: SudokuBoardProps) => {
return;
}

if (/^[1-9]$/.test(inputValue)) {
updateCellEntry(parseInt(inputValue, 10));
return;
}

let newCol = sudokuBoard.selectedCell.c;
let newRow = sudokuBoard.selectedCell.r;
switch (inputValue) {
case /^[1-9]$/.test(inputValue):
updateCellEntry(parseInt(inputValue, 10));
return;
case "Delete":
case "Backspace":
case "0":
Expand Down

0 comments on commit b940b88

Please sign in to comment.