Mousetrap – excellent keyboard shortcuts

Just discovered a great little library called mousetrap.

It enables you to have complex, chained if required, keyboard events bound in a very simple, powerful way with no reliance on an underlying library.

Example usage:

Mousetrap.bind('d', function() {
    Post.next();
});

Mousetrap.bind('a', function() {
    Post.previous();
});

Mousetrap.bind('x', function() {
    Post.delete_selected();
});

Mousetrap.bind(['command+a', 'ctrl+a'], function() {
    Post.selectAll();
});

Find out more, test and download it here, or access the git repository here.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.