There are multiple reasons of mouse not staying to your game, so i have two simple solutions that may work for you, Just follow the below steps:-
Watch the video for the same steps
1. Enable or Disable Focus Assist
Windows 11 introduces Focus Assist, which can sometimes interfere with how the mouse interacts with the system. This feature blocks notifications and distractions while gaming but might be the source of your mouse issues.
- To check and modify Focus Assist settings:
- Go to Settings > System > Focus Assist.
- Disable it completely to see if it resolves the issue.
2. Disable Virtual Desktops or Multi-Monitor Setup
In multi-monitor setups, the mouse may move between different screens, causing the cursor to leave the game window. To fix this, you can either disable the second monitor temporarily or configure Windows to prevent the mouse from moving freely between monitors.
- Disable multi-monitor setup:
- Right-click on the desktop and select Display settings.
- In the Multiple displays section, select Show only on 1 or Extend these displays to disable the second monitor.
- Alternatively, try using third-party software like Cursor Lock, which can help keep the mouse restricted to the game window.