You could try cutting the bad cable between the torn wires and the keyboard and then sacrificing another USB cable by cutting off the end you need along with as much wire as required, then stripping the ends of the two cables, match wire colors between the cables and soldering the connections. Wrap electrical tape around each connection and then tape all the connections together. Might work. New keyboards are usually available for less than $10 at various stores like Big Lots, K-mart, Walmart. Probably not economic to fix the thing unless it was an expensive mechanical gaming keyboard.
Answers & Comments
You could try cutting the bad cable between the torn wires and the keyboard and then sacrificing another USB cable by cutting off the end you need along with as much wire as required, then stripping the ends of the two cables, match wire colors between the cables and soldering the connections. Wrap electrical tape around each connection and then tape all the connections together. Might work. New keyboards are usually available for less than $10 at various stores like Big Lots, K-mart, Walmart. Probably not economic to fix the thing unless it was an expensive mechanical gaming keyboard.