Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jayphelps/shortcut.js
Add keyboard shortcuts that simulate an element being clicked
https://github.com/jayphelps/shortcut.js
Last synced: 21 days ago
JSON representation
Add keyboard shortcuts that simulate an element being clicked
- Host: GitHub
- URL: https://github.com/jayphelps/shortcut.js
- Owner: jayphelps
- Created: 2012-04-15T06:35:34.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-05-04T03:21:44.000Z (over 9 years ago)
- Last Synced: 2023-03-22T22:37:18.571Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 132 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# *This project is woefully outdated, incomplete, and naive. Don't use it, much better projects exist. Only keeping for historical reasons*
Shortcut.js
======Add keyboard shortcuts for your HTML elements to make your web app more accessible. Triggers a click event on the targeted element; usually on anchor (i.e. "a") tags but works on any, including plain old divs.
NOTE: If all you want is simple one character shortcuts on elements that allow focus, you should just use the [accesskey](http://en.wikipedia.org/wiki/Access_key) HTML attribute built into every modern browser.
Getting Started
---------------### Add through markup
``` html
Some Url>
```### Add through JavaScript
``` javascript
var element = document.getElementById('foo');
var shortcut = Shortcut.add(element, 'ctrl+a+b');
```### Remove through JavaScript
If you have a reference to the added Shortcut instance you can simply call .remove(); on it.
``` javascript
shortcut.remove();
```
Alternatively, you can call .remove() on the global Shortcut object, passing in the element node and shortcut string.``` javascript
Shortcut.remove(element, 'ctrl+a+b');
```### Compatibility
* Not all keys are implemented yet and certain browser quirks aren't normalized. This is on my todo.
* Although it doesn't require jQuery, Shortcut.js currently attempts to auto-initialize itself using jQuery's DOM Ready helper. If not available, it falls back to DOMContentLoaded or window onload for older IE.
License
------------MIT Licensed
http://www.opensource.org/licenses/mit-license.php