Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Mouse escapes the iframe in fullscreen (multi-monitor)

A topic by Fernando Frichenbruder created 9 days ago Views: 51 Replies: 1
Viewing posts 1 to 2

Is there any way to lock the mouse inside the frame? Even in fullscreen, with multiple monitors the cursor still goes outside the iframe. I know this is intended and the normal behavior, but is there any way around it? My game relies on edge-scrolling, so it kind of needs the mouse to stay within the frame.

The fine details about how to do this are difficult without knowing what type of game you’re making, or the language it’s written in. Still, assuming you’re talking about a browser game, a good place to start would be looking at the Pointer Lock API. This probably won’t be an easy drop-in solution though; you need to ask permission first, and might need to implement your own fake mouse pointer.