10 lines
440 B
JavaScript
10 lines
440 B
JavaScript
import { todo } from './todo.js'
|
|
|
|
/**
|
|
* Translate a keyboard key name (as in `KeyboardEvent.key`) into the game action it triggers, or `null`.
|
|
* m09: `ArrowUp`/`w`/`W` -> `Action.Turn('Up')`, `ArrowDown`/`s`/`S` -> Down, `ArrowLeft`/`a`/`A` -> Left,
|
|
* `ArrowRight`/`d`/`D` -> Right. Any other key -> `null`.
|
|
* (m10) `' '` (Space) -> `Action.TogglePause`, `r`/`R` -> `Action.Restart`.
|
|
*/
|
|
export const keyToAction = (key) => todo('m09')
|