In my application I have a panel which contains some settings information. This panel is opened/closed with a button click, but I'd also like to be able to close it by hitting esc
on the keyboard.
The code for my View looks like this:
Social.MainPanelView = Ember.View.extend({
elementId: 'panel-account-settings',
classNames: ['panel', 'closed'],
keypress: function(e){
console.log(e);
console.log('keypress');
},
close: function(){
this.$().prepareTransition().addClass("closed");
}
});
I've tried keyup and keydown as well but nothing happens. I suspect that it's because that this isn't an "input" type View but just a standard view. So how can I trigger a method on a View from a key event?
I should clarify that this is not within the context of a Route for this particular element. I'm opening the panel standalone as can be seen in this video:
http://screencast.com/t/tDlyMud7Yb7e
UPDATE 1
Here's a quick fiddle that I've created to illustrate the issue I'm having. I can get the click event to trigger quite easily, but I'm looking for a page wide keyup event that will detect the esc key being pressed and trigger a method on a specific View: