An open API service indexing awesome lists of open source software.

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

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)