disconnecting keyboard and mouse in games

hey i have an apex 3 keyboard and a prime mouse. At random moments during gaming they stop responding (the keyboard lights up anyway). Does anyone know what could be the cause? It doesn't happen during normal use of the computer, only when a video game is running. I would be grateful for any help.