ESC key support + 'cancel' event

- encapsulated entire code
- added ```ESC``` key support to cancel modal dialog
- fires ```cancel``` event before ```close``` on canceling modal dialog