aboutsummaryrefslogtreecommitdiff
path: root/src/controls.ts
diff options
context:
space:
mode:
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
}