I had a similar issue and I stopped having it by turning off bluetooth. I had no bluetooth device connected when the problem happened.
MBP 2013 becoming unresponsive to keyboard and mouse
I had a similar issue and I stopped having it by turning off bluetooth. I had no bluetooth device connected when the problem happened.