import { Action } from './model.js' // Key name (as in KeyboardEvent.key) -> direction. A lookup table keeps keyToAction a one-liner. const directions = { ArrowUp: 'Up', w: 'Up', W: 'Up', ArrowDown: 'Down', s: 'Down', S: 'Down', ArrowLeft: 'Left', a: 'Left', A: 'Left', ArrowRight: 'Right', d: 'Right', D: 'Right', } export const keyToAction = (key) => Object.hasOwn(directions, key) ? Action.Turn(directions[key]) : null