Hi, I don't know if this has been asked before, but I was wondering if there's a best practice for implementing keyboard shortcuts in ember apps


#1

My initial thoughts around implementing them is as a mixin which is mixed in to application controller and letting the application controller deal with the keyboard shortcuts logic because the user can invoke those shortcuts on any route. Does that make sense? Is there a better/more flexible solution to this? Thanks in advance!


#2

Typically you don’t want DOM events bubbling to your controllers and then up the route path, that’s not a good layering of concerns.

You may instead use a view mixin which handles certain universal keyboard events and then maps to a meaningful/semantic controller action (ie ‘remove’ or ‘select’, ‘cancel’ etc). That way if the controller doesn’t handle it, the action will bubble up the route path to the first route that handles it and failing that a default action handler on your application route if you have specified one.