Use via.OnKeyDownMap for snake keybindings, replacing the manual dataExpr/rawDataAttr workaround. Window-scoped key handling removes the need for tabindex/focus hacks, and WithPreventDefault on arrow keys prevents page scrolling during gameplay. Introduce a 60 FPS tick loop with a separate snake movement speed (7 cells/s) so direction input is polled every frame but game state only advances at the configured rate.
3.6 KiB
3.6 KiB