ccampbell/mousetrap — pull request #154 by dtao (2013-08-19 17:10:06+00:00)
Title: Wrapping specific elements

I've wanted this for a while: adding the ability for Mousetrap to target specific elements rather than the entire document. This is really useful if, e.g., you want to provide keyboard shortcuts to a specific `` or an element with the `contenteditable` attribute, but don't want these shortcuts to affect the rest of the document.

I've made the change backwards compatible with the way the library works by default. I.e., `Mousetrap.bind()` still works at the document level. To handle keyboard shortcuts only bubbling from from a specific element, you use `wrap()`:

```javascript
Mousetrap.wrap(element).bind('sequence', callback);
```

I kind of wanted the API like this:

```javascript
Mousetrap(element).bind('sequence', callback);
```

...but that would have involved more code.

I know it *looks* like a big diff, but that's mainly because of the indentation changes. To see a cleaner diff, you can use `git diff --ignore-space-change`.