ESC to close view


#1

Hi there, I’m developing a new package for Atom and I’m having a problem in binding the ESC button with the view. I tried to follow the find-and-replace code to get an idea of how to do it but I haven’t been very successful.

I usually prefer to discover stuff on my own but I’ve spent the last weekend banging my head on it so I’m here asking for some help.

This is the package: https://github.com/stesix/comment-this

Can someone give it a check and tell me what I’m not figuring out? At the moment it’s a little bit spaghetti-code since as soon as I have an idea I adapt the code.

Thank you in advance

EDIT: Given my coffeescript knowledge, any suggestion for improving the coding is also very welcome. Thanx


#2

It looks like the keybinding-resolver package has a simpler implementation that just hooks in to the Esc being pressed on the workspace:

https://github.com/atom/keybinding-resolver/blob/master/lib/main.coffee


#3

Thank you, this partially solves the problem. I’m now able to hide the panel pressing ESC unless I’ve got one of the fields focused (which unfortunately it’s what I do).

Anyway, oh joy, it’s a step forward. :smile:

EDIT: for some magical reasons the core:confirm works like charm but neither the core:close or core:cancel do.