1

Does ember have a way to allow ember components to capture/listen to global keypress events without having to set focus (as described by the attached links)?

Is there an elegant way of doing this in the latest version on Ember ?

Global keyDown/keyPress events in EmberJS without having to set focus

Ember.js: View listening for keypress event

Community
  • 1
  • 1
Shivam Sinha
  • 4,924
  • 7
  • 43
  • 65

1 Answers1

1

FYI best way to implement this is to use the Mousetrap.js http://craig.is/killing/mice

Ember CLI instructions

  1. bower install --save mousestrap

  2. Add /* global Mousetrap */ to the top of the file you want to use mouse trap in (which in my case was a custom component

  3. Example usage:

    didInsertElement: function() {
     Mousetrap.bind('right', function() {
          alert('right direction arrow clicked');
        });
    }
    
Shivam Sinha
  • 4,924
  • 7
  • 43
  • 65