Apple - OS X esc key stops working (randomly)
For anyone who ends up here after installing the macOS Sierra release candidate. I had to disable Siri and then kill the Siri process using Activity Monitor.
I've been having the same exact issue for a couple of weeks, and it did turn out it was indeed the Visor feature from TotalFinder as mentioned before by Joe. Disabling it did solve the thing.
Anyway, as it has been said, given the fact that the behaviour is the same with the built-in keyboard or the bluetooth one, it's obvious it's not a hardware issue.
If this problem happens in every application then it is indeed a system wide problem. If it only happens in one application it's an application problem.
This problem might also come from another (modifier) key getting stuck.
To check if the Esc key is ignored by the system itself or if another key is stuck use the Keyboard Viewer:
Go to Apple → System Preferences...
→ Keyboard
Enable Show Keyboard & Character Viewers in menu bar
Then when the problem happens again display the keyboard viewer and check if any keys are stuck. If not try using the esc key there and see if it displays as being pressed. If not then you probably have a driver problem.
You could then try installing your system on another drive and try to reproduce the issue on a clean install.