Mid 2014 Macbook Pro randomly stops responding (keyboard and trackpad won't do anything)
This will probably sound strange, but I had a short of similar issue on my MacBook Pro.

It turned out I was somehow accidentally managing to trigger the "Swipe between full-screen apps" gesture just a tiny almost imperceptible bit. It took me ages to figure this out. But while it is partially through a swipe nothing else seems to register on the keyboard or trackpad.

If this is the problem you can just do a little horizontal three or four (depending on how you have it set) finger wiggle to reset it, or turn the swipe off in System Preferences.