https://github.com/ghostffcode/keybinder
:key: Simple Javascript Keybinder
https://github.com/ghostffcode/keybinder
Last synced: about 1 year ago
JSON representation
:key: Simple Javascript Keybinder
- Host: GitHub
- URL: https://github.com/ghostffcode/keybinder
- Owner: ghostffcode
- License: mit
- Created: 2016-09-20T22:44:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-10T04:59:50.000Z (over 9 years ago)
- Last Synced: 2024-10-18T20:48:34.437Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://ghostffcode.github.io/keybinder/
- Size: 157 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# keybinder - Simple Javascript Keybinder
---
## Installation
```
npm i keybinder --save
```
## To Use
```javascript
keybinder(selector, keys, callback);
```
The arguments for the keybinder are:
* __Selector (String)__: The DOM selector for elements that you want to bind the keys to.
* __keys (Array)__: Array of key combinations to listen to.
* __callback (function)__: The callback function to run when the specified key combinations are pressed. This is automatically bound to the element selected.
## Implement
In node, require:
```javascript
const keybinder = require("keybinder");
```
Or in HTML use:
```html
keybinder('.name', ['control', 's'], function () {
// this refers to element with .name as class
this.value = 'I am changed';
});
```
## Contributing
Is there something you think it is missing? Great!
- Fork this repo
- Make changes, write tests
- Send a pull request
### License
Keybinder is licensed under the [MIT License](../master/LICENSE)