From 387cdff80cb3e2c6199e2148ade083160f31ca96 Mon Sep 17 00:00:00 2001 From: eideard-hm Date: Wed, 20 Sep 2023 15:18:20 -0500 Subject: [PATCH] refactor: hard code moves to EVENT_MOVEMENTS constants on key events --- consts.js | 3 ++- main.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/consts.js b/consts.js index 7f09454..14c3ef0 100644 --- a/consts.js +++ b/consts.js @@ -5,7 +5,8 @@ export const BOARD_HEIGHT = 30 export const EVENT_MOVEMENTS = { LEFT: 'ArrowLeft', DOWN: 'ArrowDown', - RIGHT: 'ArrowRight' + RIGHT: 'ArrowRight', + UP: 'ArrowUp' } export const PIECES = [ diff --git a/main.js b/main.js index 46221d4..a2d8985 100644 --- a/main.js +++ b/main.js @@ -265,7 +265,7 @@ document.addEventListener('keydown', event => { } } - if (event.key === 'ArrowUp') { + if (event.key === EVENT_MOVEMENTS.UP) { const rotated = [] // ESTO ES LO MÁS COMPLICADO DE LEJOS