2 var _ = require('lodash');
3 var appEvents = require('../utils/appevents');
4 require('../components/keyboard-events');
6 module.exports = (function() {
7 // Bind `keyboardEvents` names to functions or method names, as you would with Backbones' `events`
8 // See/change components/keyboard-events for events listeners
11 initialize: function() {
13 if (!(events = _.result(this, 'keyboardEvents'))) return;
16 var eventSplitter = /\s+/;
18 var _listen = function(key, method) {
19 if (!_.isFunction(method)) method = self[method];
21 self.listenTo(appEvents, 'keyboard.' + key, method, self);
25 _.each(events, function(method, key) {
26 if (eventSplitter.test(key)) {
27 var keys = key.split(eventSplitter);
28 _.each(keys, function(k) {