-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from defaude/rewrite
Full rewrite
- Loading branch information
Showing
20 changed files
with
90 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[package.json] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
.idea | ||
.DS_Store | ||
/node_modules/ | ||
/bower_components/ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
.editorconfig | ||
test/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,49 @@ | ||
# Logitech R800 Presenter keys made easy | ||
# presenter-keys | ||
|
||
A super-simple jQuery plugin that provides callbacks for all four action keys on the sweet [Logitech R800 Presenter](http://www.logitech.com/en-ch/support/professional-presenter-r800). | ||
Tiny no-dependency library that allows you to easily bind actions to the keys of presenters like e.g. the | ||
[Logitech R800 Presenter](http://www.logitech.com/en-ch/support/professional-presenter-r800). | ||
|
||
Those kinds of presenters are basically keyboards that will send the following key codes: | ||
|
||
Basically, the presenter is a USB keyboard that will send the following key codes: | ||
* Previous => PageUp (33) | ||
* Next => PageDown (34) | ||
* Run => Alternating between F5 (116) and Escape (27) | ||
* Blank => A simple dot (190) | ||
|
||
## Getting Started | ||
## Direct usage | ||
|
||
Download the [production version][min] or the [development version][max]. | ||
Simply import the `presenterKeys` function module and call it with the callback functions you want to attach to the | ||
different keys: | ||
|
||
[min]: https://raw.github.com/defaude/jquery-jquery-r800-keys/master/dist/jquery.jquery-r800-keys.min.js | ||
[max]: https://raw.github.com/defaude/jquery-jquery-r800-keys/master/dist/jquery.jquery-r800-keys.js | ||
```html | ||
|
||
Call the plugin on any jQuery-wrapped DOM node (`document` should do the trick for most use cases, though.) and pass an object containing the callbacks: | ||
<script type="module"> | ||
import { presenterKeys } from "https://unpkg.com/@defaude/presenter-keys"; | ||
```html | ||
<script src="jquery.js"></script> | ||
<script src="dist/jquery-r800-keys.min.js"></script> | ||
<script> | ||
jQuery(function($) { | ||
$(document).r800Keys({ | ||
prev: function () { alert('prev'); }, | ||
next: function () { alert('next'); }, | ||
run: function () { alert('run'); }, | ||
blank: function () { alert('blank'); } | ||
}); | ||
}); | ||
presenterKeys({ | ||
prev: () => console.log('prev'), | ||
next: () => console.log('next'), | ||
run: () => console.log('run'), | ||
blank: () => console.log('blank') | ||
}); | ||
</script> | ||
``` | ||
|
||
Note: You don't have to pass all four callbacks. If you're just interested in the `prev` and `next` keys, for example, you could pass an object only containing those two. | ||
Based on the available keys, the four available callbacks are `prev`, `next`, `run` and `blank`. You don't need to pass | ||
all four callbacks - maybe you just need `prev` and `next` in most cases. | ||
|
||
## Installation as npm package | ||
|
||
This is published as npm package, so you can just | ||
|
||
```shell | ||
npm install @defaude/presenter-keys | ||
``` | ||
|
||
and use it in your code | ||
|
||
## Release History | ||
2014-02-23 1.0.3 Switched to Grunt-based build :) | ||
```js | ||
import { presenterKeys } from '@defaude/presenter-keys'; | ||
|
||
presenterKeys({ /* ... */ }); | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const noop = () => undefined; | ||
|
||
export function presenterKeys(callbacks, element = document.body) { | ||
const settings = { | ||
prev: noop, next: noop, run: noop, blank: noop, | ||
...callbacks | ||
}; | ||
|
||
const keyHandlers = { | ||
PageUp: settings.prev, | ||
PageDown: settings.next, | ||
F5: settings.run, | ||
Escape: settings.run, | ||
'.': settings.blank | ||
}; | ||
|
||
element.addEventListener('keydown', event => { | ||
if (event.key in keyHandlers) { | ||
event.preventDefault(); | ||
keyHandlers[event.key](); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,15 @@ | ||
{ | ||
"name": "r800-keys", | ||
"version": "1.0.2", | ||
"description": "Logitech R800 Presenter keys made easy", | ||
"keywords": [ | ||
"jquery-plugin" | ||
], | ||
"homepage": "https://github.com/defaude/jquery-r800-keys", | ||
"bugs": "https://github.com/defaude/jquery-r800-keys/issues", | ||
"name": "presenter-keys", | ||
"version": "1.0.3", | ||
"description": "Presenter keys made easy", | ||
"license": "WTFPL", | ||
"repository": "defaude/presenter-keys", | ||
"author": { | ||
"name": "Roland Hummel", | ||
"email": "git@defaude.info", | ||
"url": "https://github.com/defaude" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/defaude/jquery-r800-keys.git" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "WTFPL" | ||
} | ||
], | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "~0.7.2", | ||
"grunt-contrib-qunit": "~0.3.0", | ||
"grunt-contrib-concat": "~0.3.0", | ||
"grunt-contrib-uglify": "~0.2.7", | ||
"grunt-contrib-watch": "~0.5.3", | ||
"grunt-contrib-clean": "~0.5.0", | ||
"grunt-contrib-connect": "~0.5.0", | ||
"time-grunt": "~0.2.3", | ||
"load-grunt-tasks": "~0.2.0", | ||
"jshint-stylish": "~0.1.3", | ||
"grunt": "~0.4.2" | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.