Skip to content

Commit

Permalink
Full rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
defaude committed Oct 2, 2021
1 parent b8128f3 commit 8282de4
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 463 deletions.
3 changes: 0 additions & 3 deletions .bowerrc

This file was deleted.

12 changes: 12 additions & 0 deletions .editorconfig
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
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
.idea
.DS_Store
/node_modules/
/bower_components/
dist
21 changes: 0 additions & 21 deletions .jshintrc

This file was deleted.

3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
.editorconfig
test/
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

32 changes: 0 additions & 32 deletions CONTRIBUTING.md

This file was deleted.

99 changes: 0 additions & 99 deletions Gruntfile.js

This file was deleted.

File renamed without changes.
57 changes: 34 additions & 23 deletions README.md
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({ /* ... */ });
```
9 changes: 0 additions & 9 deletions bower.json

This file was deleted.

23 changes: 23 additions & 0 deletions index.js
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]();
}
});
}
36 changes: 7 additions & 29 deletions package.json
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"
}
}
33 changes: 0 additions & 33 deletions r800-keys.jquery.json

This file was deleted.

15 changes: 0 additions & 15 deletions src/.jshintrc

This file was deleted.

Loading

0 comments on commit 8282de4

Please sign in to comment.