Hacker News new | ask | show | jobs
by selectnull 1403 days ago
Just like few others here, I wanted keyboard shortcuts so I just hacked it quickly. Will break if DOM classes change, but author should implement something better.

Cool game.

```

const rotate = (direction) => { const directions = {counterclockwise: 0, clockwise: 1}; const buttons = Array.from(document.querySelector('.mt-16.flex.items-center.justify-between.w-72.h-12.px-2').querySelectorAll('div')).filter(el => el.className === ''); buttons[directions[direction]].click(); }

document.addEventListener('keydown', (ev) => { switch (ev.key) { case 'ArrowLeft': rotate('counterclockwise'); break; case 'ArrowRight': rotate('clockwise'); break; } });

```

2 comments

Thanks a lot! I just added the keyboard shortcuts :)
It is neat that the modern browser, for all its flaws, is so easily hackable