aboutsummaryrefslogtreecommitdiff
path: root/src/controls.ts
diff options
context:
space:
mode:
authorJoris2022-07-05 22:11:00 +0200
committerJoris2022-07-05 22:11:00 +0200
commit8c1ab4c5756ac43d52bc8773f5e72dde90f79e77 (patch)
treede0db8c859e4204c90ddaa762f4d743fab1dedb2 /src/controls.ts
parent1d855b7a50b61650f7ddf40f604c788de1c9e914 (diff)
WIP
Diffstat (limited to 'src/controls.ts')
-rw-r--r--src/controls.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/controls.ts b/src/controls.ts
index b575b3f..8ae0dbf 100644
--- a/src/controls.ts
+++ b/src/controls.ts
@@ -3,7 +3,7 @@ export interface Controls {
right: boolean,
down: boolean,
left: boolean,
- space: boolean,
+ spaceCount: number,
}
export let current = {
@@ -11,7 +11,7 @@ export let current = {
right: false,
down: false,
left: false,
- space: false,
+ spaceCount: 0,
}
document.addEventListener('keydown', event => {
@@ -31,8 +31,8 @@ function update(current: Controls, key: string, isDown: boolean): Controls {
return { ...current, down: isDown }
else if (key === 'ArrowLeft')
return { ...current, left: isDown }
- else if (key === ' ')
- return { ...current, space: isDown }
+ else if (key === ' ' && !isDown)
+ return { ...current, spaceCount: current.spaceCount + 1 }
else
return current
}