MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / changeKeyboardPosition

Function changeKeyboardPosition

assets/js/sudoku.js:639–696  ·  view source on GitHub ↗
(direction)

Source from the content-addressed store, hash-verified

637 //add keyboard functionality
638 var keyboardInputPosition = 0;
639 function changeKeyboardPosition (direction) {
640 var kip = keyboardInputPosition;
641 if (!direction) {return }
642
643 board.board[kip].dom.style.backgroundColor = '#e5ecf3';
644 function returnNextPos(direction){
645 //left
646 if (direction == 37) {
647 if (board.board[kip].y == 0 && board.board[kip].x == 0) {
648 kip = 80;
649 } else {
650 kip--;
651 }
652 };
653 //right
654 if (direction == 39) {
655 if (board.board[kip].y == 8 && board.board[kip].x == 8) {
656 kip = 0;
657 }else{
658 kip++;
659 }
660 };
661 //up
662 if (direction == 38) {
663 if (board.board[kip].x == 0) {
664 if (board.board[kip].y == 0) {
665 kip = 80;
666 } else {
667 kip += 71
668 }
669 } else {
670 kip -= 9;
671 }
672 };
673 //down
674 if (direction == 40) {
675 if (board.board[kip].x == 8) {
676 if (board.board[kip].y == 8) {
677 kip = 0;
678 } else {
679 kip -= 71
680 }
681 } else {
682 kip += 9;
683 }
684 };
685 }
686 returnNextPos(direction)
687 while (board.board[kip].dom.classList.contains('noDrop')) {
688 returnNextPos(direction);
689 }
690
691 board.board[kip].dom.style.backgroundColor = 'white';
692 keyboardInputPosition = kip;
693 window.setTimeout(function() {
694 board.board[kip].dom.style.backgroundColor = '#e5ecf3';
695 }, 1500);
696 }

Callers 1

sudoku.jsFile · 0.85

Calls 1

returnNextPosFunction · 0.85

Tested by

no test coverage detected