/** * Keyboard play, layered on top of forms that already work without it. * Every control on the page is a real submit button; this just finds the one * a keypress means and presses it. No fetch, no state, no rendering — the * server owns the turn either way. */ (function () { var KEYS = { ArrowUp: "north", ArrowDown: "south", ArrowLeft: "west", ArrowRight: "east", w: "north", s: "south", a: "west", d: "east", k: "north", j: "south", h: "west", l: "east", ".": "wait", " ": "wait", ">": "descend", "<": "ascend", }; document.addEventListener("keydown", function (event) { if (event.metaKey || event.ctrlKey || event.altKey) return; var action = KEYS[event.key]; if (!action) return; var button = document.querySelector('button[value="' + action + '"]'); if (!button) return; event.preventDefault(); button.focus(); button.click(); }); })();