Fixed bugs in support for escape and enter keys.

They weren't working, and now they are. And I added a whole bundle of
comments.