Skip to content

Commit

Permalink
fixed keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Elixonus committed Jan 31, 2023
1 parent 419596e commit 3df52c2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cardsort/cardsort.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function render()
{
//LOGIC

if(keys.includes(38))
if(keys.includes("ArrowUp") || keys.includes("w") || keys.includes("W"))
{
camera.y -= 3;

Expand All @@ -101,7 +101,7 @@ function render()
}
}

if(keys.includes(40))
if(keys.includes("ArrowDown") || keys.includes("s") || keys.includes("S"))
{
camera.y += 3;

Expand All @@ -111,7 +111,7 @@ function render()
}
}

if(keys.includes(37))
if(keys.includes("ArrowLeft") || keys.includes("a") || keys.includes("A"))
{
camera.x -= 3;

Expand All @@ -121,7 +121,7 @@ function render()
}
}

if(keys.includes(39))
if(keys.includes("ArrowRight") || keys.includes("d") || keys.includes("D"))
{
camera.x += 3;

Expand Down Expand Up @@ -175,21 +175,21 @@ function addKey(e)
{
e = e || window.event;

if(!keys.includes(e.keyCode))
if(!keys.includes(e.key))
{
keys.push(e.keyCode);
keys.push(e.key);
}
}

function subtractKey(e)
{
e = e || window.event;

if(keys.includes(e.keyCode))
if(keys.includes(e.key))
{
for(var n = 0; n < keys.length; n++)
{
if(keys[n] == e.keyCode)
if(keys[n] == e.key)
{
keys.splice(n, 1);
}
Expand Down

0 comments on commit 3df52c2

Please sign in to comment.