Made with by chieffancypants

AngularHotkeys.js

Configuration-centric keyboard shortcuts for your angular apps
Download Zip View on GitHub

Fully route-aware

Automatically binds and unbinds keys as you navigate the app

Configuration centric

No messy DOM attributes to litter your templates

Automatic Help

Creates a pretty cheat sheet automatically

What is this?

Put simply, managing shortcuts via the DOM is a nightmare:

<!-- player.html: -->
<div class="player" shortcut="{space: playPause, 'alt+right': forward30, 'ctrl+right': forward60, 'left': back30, 'ctrl+left': back60, up: volumeUp, down: volumeDown, 'ctrl+down': mute, 'ctrl+up': unmute, f: fullscreen, h: showHelp, m: muteToggle, right: nextChapter, left: previousChapter, c: toggleCaptions}">
  <div class="playPause-btn"></div>
  <div class="mute-btn"></div>
</div>

Your DOM is littered with attributes making it hard to read, and moreover, managing the shortcuts over dozens of templates is very tedious.

What makes this different?

This project is quite a bit different from any other angular-based keyboard shortcut libraries. It is aimed at creating configurable shortcuts in javascript, instead of as directives in the DOM. While tying the shortcuts to DOM elements may work for some Angular apps, mine rarely have a 1-to-1 relationship between DOM elements and controller methods. In my case, many methods on the controller were only accessible through the keyboard.

Read more

What about the cheat-sheet?

Well, go ahead and try it. Hit the ? key. As you create shortcuts, they will appear automatically in the cheat-sheet when they are active. This means the cheat-sheet is route aware as well, and will only show shortcuts that work for the current application's state.

License

The MIT License (MIT)

Copyright (c) 2014 Wes Cruver

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Download Zip View on GitHub
Made with by chieffancypants
{{ key }}