Skip to content

Commit

Permalink
added remove on wasd
Browse files Browse the repository at this point in the history
  • Loading branch information
BazhenovDev committed Jan 1, 2025
1 parent e90bf93 commit 0c24848
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/js/modules/snake.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export class Snake {

addKeyboardHandler() {
document.addEventListener('keydown', (event) => {
if (event.key === 'ArrowLeft' && this.currentDirection !== 'right') {
if (event.key === 'ArrowLeft' || event.key === 'a' || event.key === 'ф' && this.currentDirection !== 'right') {
this.currentDirection = 'left';
} else if (event.key === 'ArrowRight' && this.currentDirection !== 'left') {
} else if (event.key === 'ArrowRight' || event.key === 'd' || event.key === 'в' && this.currentDirection !== 'left') {
this.currentDirection = 'right';
} else if (event.key === 'ArrowUp' && this.currentDirection !== 'down') {
} else if (event.key === 'ArrowUp' || event.key === 'w' || event.key === 'ц' && this.currentDirection !== 'down') {
this.currentDirection = 'up';
} else if (event.key === 'ArrowDown' && this.currentDirection !== 'up') {
} else if (event.key === 'ArrowDown' || event.key === 's' || event.key === 'ы' && this.currentDirection !== 'up') {
this.currentDirection = 'down';
}
});
Expand Down

0 comments on commit 0c24848

Please sign in to comment.