https://github.com/koding/keyconfig
https://github.com/koding/keyconfig
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/koding/keyconfig
- Owner: koding
- License: mit
- Created: 2015-03-05T11:23:18.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-02-14T21:17:37.000Z (almost 9 years ago)
- Last Synced: 2024-11-11T21:31:58.006Z (about 1 year ago)
- Language: CoffeeScript
- Size: 58.6 KB
- Stars: 1
- Watchers: 9
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
# keyconfig
stores keyboard shortcut definitions.
# usage
```js
var keyconfig = new Keyconfig({
x: [
{
name: 'foo',
binding: [ [ 'ctrl+z' ], [ 'command+z' ] ]
}
]
});
keyconfig
.on('change', function (collection, model) { });
.find({ name: 'x '})
.find({ name: 'foo' })
.update({ binding: ['command+d'] });
```
# spec
Below is an example of a collection:
```json
{
"editor":
[
{
"name": "save",
"description": "Save",
"binding": [
[ "ctrl+s" ],
[ "command+s" ]
],
"options": {
"enabled": true
}
}
]
}
```
### fields
- `name` must be unique
- `binding` is an array of two arrays that defines win and mac shortcuts respectively
- `description` is description text
- `options` is always extended when you do `update`
# api
# keyconfig(collections={})
# Collection(name, models=[])
## .add(model)
## .update(name, value={}, silent=false)
## .toJSON()
## .getCollidingWin()
## .getCollidingMac()
`Keyconfig` and `Collection` instances also proxy underscore methods.
# Model(value={})
## .update(value={}, silent=false)
## .getWinKeys()
## .getMacKeys()
## .getWinChecksum()
## .getMacChecksum()
## .toJSON()
Updating a model triggers a `change` event that bubble up.
# license
mit