Backbone.js + Keymaster.js = Backbone.Shortcuts (Keyboard shortcuts)
Backbone.js + Keymaster.js = Backbone.Shortcuts (Keyboard shortcuts)
Backbone.js + Keymaster.js = Backbone.Shortcuts.
_.extend() functionBackbone classHTML
Place snippets inside of the ... tags.
JavaScript
var ShortcutKeys = Backbone.Shortcuts.extend({
shortcuts: {
"ctrl+r" : "reloadPage"
},
reloadPage: function() {
alert("Reloaded!!");
}
});
var shortcuts = new ShortcutKeys;CoffeeScript
class ShortcutKeys extends Backbone.Shortcuts
shortcuts:
"ctrl+r" : "reloadPage"
reloadPage: -> alert "Reload!!!"
shortcuts = new ShortcutKeysFinally, you can press Ctrl + r to execute reloadPage() function to see the alert message.
You have to _.extend the this as desination and new Backbone.Shortcuts as source then finally call the delegate function this.delegateShortcuts();.
Bryan Goines, @bryangoines
Backbone.Shortcuts is licensed under MIT license.
No open issues yet, or sync has not completed.