kytrinyx/exercism.io — pull request #578 by martinsvalin (2013-08-20 14:10:33+00:00)
Title: Close notifications on Esc

This will close the notifications list when ESC is pressed, as discussed in #445 and #269.

I check if the list is visible, if any inputs have focus (in which case the user may be typing, and we don't really want to toggle anything for the poor Vim-people who habitually hit esc while typing), and if the key is indeed esc. If so, toggle that list.

I'd really like another pair of eyes on this before merging, especially since I'm don't usually do a lot of front end development. There are no tests, which makes me uncomfortable, but I don't have a lot of experience writing js-tests that hit the DOM, and I couldn't find any other js tests. "It works on my computer". ;)

Unfortunately I couldn't bind the keyup event with the normal backbone events, which is why I bindAll. See http://stackoverflow.com/questions/6033010/how-to-capture-the-key-event-from-a-view for details.