This could be an issue with power management settings. Try going to Device Manager > Keyboards > Right click on your keyboard > Properties > Power Management > Uncheck "Allow the computer to turn off this device to save power". If this doesn't work, try updating your keyboard drivers.