ESC key closes modals

Add a key handler that calls hide() when ESC (keycode 27) is pressed.
Configurable with the escToCancel flag.