DEV Community

Nevin Katz
Nevin Katz

Posted on

Handling touch and mouse events with JavaScript

Since I was young programming on a Commodore 128, I have learned a fair bit of programming by building games.

One particular interest I have is building dungeon crawlers and maze games. Recently I have been learning more about how to handle both mouse events and touch events in a JavaScript maze game I have been building.

While working on fine-grained controls that rely on when touch or click events start and end, I learned about how to get a set of button controls to respond to both touch events and mouse events without having both fire at the same time.

If you are building games or apps and interested in solving similar play control problems, check out my article on separating mouse and touch events, recently published on CodeX. I break down the problem I ran into and have a few code snippets that convey how I solved it.

Thanks for reading!

Top comments (0)