Is everything connected? It usally does that when you connect the m/k directly to the console instead of it being connected through the keymander. Try pressing f9 while in game see if that works
If any of you are on ps4 what i found out was that my mouse cord was moving the cord connected to my controller causing it to disconnect try changing the cord connected to your controller