Touch controls not responding
Unresponsive touch controls usually come from mouse-only input code, an invisible element on top of the game, wrong coordinate scaling, or only tracking one finger.

Key takeaways
- Use pointer events (pointerdown, pointermove, pointerup) instead of mouse events, and track each finger by its pointer ID.
- An invisible overlay or a menu container sitting on top of the canvas swallows taps more often than people expect.
- If taps land in the wrong place, the canvas is scaled and the code is not converting screen coordinates to game coordinates.
When touch controls do not respond in a browser game, the most likely cause is input code written for a mouse: it listens for clicks or mouse events and tracks a single cursor, so a phone either ignores taps, reacts late, or loses track when a second finger lands. The second most common cause is an invisible element on top of the game (a transparent menu layer, a full-screen div) that receives the taps instead of the canvas.
Pin down how it fails
Different failures point to different causes. Before you debug, note which one you see on a real phone:
- Nothing responds anywhere: an overlay is on top, or the code only listens to mouse events.
- Some areas respond, others do not: an element covers part of the screen, often the HUD container.
- Taps register in the wrong spot: coordinate scaling.
- Moving works until you press jump: single-pointer tracking; the second finger hijacks the first.
- The page scrolls or zooms instead: browser gestures are not disabled for the game area.
- Responds, but late: heavy frames or a click delay. See the frame-rate section below.
The causes, most likely first
1. Mouse-only input code
Phones do fire emulated mouse events after a tap, but only for simple single taps, sometimes with a delay, and never for drags with two fingers. How to check: search the input code for `mousedown`, `mousemove` and `click`. The fix: switch to pointer events (`pointerdown`, `pointermove`, `pointerup`, `pointercancel`). They cover mouse, touch and pen with one code path. Handle `pointercancel` too: the browser fires it when a system gesture takes over, and ignoring it leaves a virtual button stuck "held".
2. Something invisible on top
A pause menu that fades to `opacity: 0` but is still there, a full-screen wrapper for the HUD, or a transparent loading screen that never got removed will catch every tap. How to check: in a desktop browser with the phone-size view, right-click the spot and Inspect: the element highlighted is the one receiving input. If it is not the canvas or your button, that is the culprit. The fix: remove hidden layers from the page, or set `pointer-events: none` on HUD containers and `pointer-events: auto` only on the buttons inside them.
3. Coordinates not converted
Games often render to a fixed internal size (say 1280 by 720) and scale the canvas to fit the screen. A tap at screen position 200, 300 is not game position 200, 300. How to check: draw a small dot where the game thinks you tapped. If it drifts away from your finger toward the edges, scaling is off. The fix: convert using the canvas's on-screen rectangle: subtract its left and top, then multiply by the internal width divided by the displayed width (and the same for height). Engines like PixiJS have helpers for this; custom code needs it written once and used everywhere.
4. Only one finger tracked
A virtual joystick on the left and a jump button on the right need two simultaneous touches. Code that stores "the" touch position gets confused when the second finger lands: the joystick jumps to the button, or the character stops. How to check: hold the joystick, then tap jump. The fix: track each pointer by its `pointerId`. When a finger goes down, assign it to whatever control it started on, and keep that assignment until that same pointer lifts, no matter where it moves. This is the single most important pattern for twin-control games.
5. The browser handles the gesture instead
Without the right settings, a swipe scrolls the page, a double tap zooms, and a long press opens the text magnifier or a context menu. The fix: set `touch-action: none` on the game canvas, disable text selection on the game area, and prevent the context menu on long press. Startbase games are built to feel native on phones out of the box: published games block page zoom, scrolling and the text magnifier over play. If you see those gestures anyway, a custom element added later probably sits outside the protected area; ask the agent to apply the same rules to it.
6. preventDefault in a passive listener
To keep scrolling smooth, browsers treat touch listeners on the page, window and body as passive by default, which means calling `preventDefault()` inside them does nothing (Chrome logs a warning in the console). Code that relies on it to stop the page scrolling during a swipe silently fails. The fix: attach input listeners to the game canvas itself rather than the document, pass `{ passive: false }` explicitly where you really need to cancel the default, and prefer `touch-action: none` in CSS, which stops the gesture before any script runs.
7. Buttons too small or too close to the edge
A 32-pixel button is easy to click with a mouse and easy to miss with a thumb. Controls placed at the very bottom of the screen also compete with the phone's home gesture bar. The fix: make touch targets at least 44 to 48 points, give the hit area more room than the visible art, and keep controls inside the safe area (above the home indicator and away from rounded corners). Test with your thumbs, holding the phone the way a player would.
8. Input handled once per frame on a slow frame
If the game runs at 20 frames per second, input feels sluggish even when the code is correct. The fix: record input in the event handlers as it happens, read it in the game loop, and fix the frame rate itself. Our guide to why games lag on iPhone covers the usual causes.
Test on a phone, with two thumbs
The Startbase preview has a Phone view that is great for layout, but a mouse cannot press two buttons at once or swipe like a thumb. Open the published game or a shared preview link on a real phone for any input work. The agent also playtests in a real browser by tapping and pressing keys, which catches errors and dead screens, but you are the best judge of how controls feel.
The message to send the agent
On phones, the left virtual joystick works until I press the jump button on the right; then the character stops and the joystick snaps toward the jump button. Taps near the screen edges also land slightly off. Please: switch all game input to pointer events, track each finger by pointerId so the joystick and buttons work at the same time, handle pointercancel so no control stays stuck, convert screen coordinates to game coordinates using the canvas rectangle, make every touch button at least 48 px with a larger hit area, and keep controls inside the safe area. Show a debug dot where each touch lands, behind a debug flag.
For designing the controls themselves (virtual sticks vs tap zones vs swipes), read mobile game touch controls. If the controls work but the game is silent, see game sound not playing on mobile. The games docs describe what is set up for phones by default.
Frequently asked questions
Why does my game work with a mouse but not on touch screens?
The input code listens for mouse events. Phones only emulate simple mouse clicks. Switch to pointer events, which handle mouse, touch and pen together.
How do I support two fingers at once?
Track each touch by its pointerId and bind it to the control it started on until that pointer lifts.
How big should touch buttons be?
At least 44 to 48 points, with a hit area larger than the visible button, and placed away from the screen edges and the home indicator.
Why does the page scroll when I swipe in my game?
The browser is handling the gesture. Set touch-action: none on the game canvas so swipes go to the game.

