Skip to content

Commit

Permalink
Initial commit (#1)
Browse files Browse the repository at this point in the history
* Initial commit

* Tweak

* Remove test workflows

* Add output

* Add key types

* Remove key types
  • Loading branch information
PauloMFJ authored Oct 4, 2021
1 parent 4c08677 commit 88b908c
Show file tree
Hide file tree
Showing 10 changed files with 12,227 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @digitaljohn
* @paulomfj @digitaljohn
3 changes: 1 addition & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: npm install, build, and test
- name: npm install and build
run: |
npm ci
npm run build --if-present
npm run lint
npm test
env:
CI: true
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: npm install, build, and test
- name: npm install and build
run: |
npm ci
npm run build --if-present
npm run lint
npm test
env:
CI: true

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ I'm really happy that you're interested in helping out with this little project.

As this is very early days for the project there's not a lot in the way of
resources, but please check out the [documentation](./README.md), and also the
[list of issues](https://github.com/phantomstudios/PACKAGE-NAME/issues).
[list of issues](https://github.com/phantomstudios/use-key/issues).

Please submit an issue if you need help with anything.

Expand All @@ -20,7 +20,7 @@ pass. Testing is automated using GitHub Actions CI.
## Submitting changes

Please send a
[GitHub Pull Request to PACKAGE-NAME](https://github.com/phantomstudios/PACKAGE-NAME/pull/new/master)
[GitHub Pull Request to use-key](https://github.com/phantomstudios/use-key/pull/new/master)
with a clear list of what you've done (read more about
[pull requests](https://help.github.com/en/articles/about-pull-requests)). When you send a pull
request, please make sure you've covered off all the points in the template.
Expand All @@ -43,6 +43,6 @@ In effect this means:
- Your Pull Request title and description become very important; they are the
history of the master branch and explain all the changes.
- You ought to be able to find any previous version easily using GitHub tabs, or
[Releases](https://github.com/phantomstudios/PACKAGE-NAME/releases)
[Releases](https://github.com/phantomstudios/use-key/releases)

Thanks, John Chipps-Harding
94 changes: 29 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,54 @@
# PACKAGE-NAME
# use-key

[![NPM version][npm-image]][npm-url]
[![Actions Status][ci-image]][ci-url]
[![PR Welcome][npm-downloads-image]][npm-downloads-url]

Package one-liner overview.

## Introduction

Package introduction, couple of paragraphs.

```javascript
import useLibrary from "@phntms/PACKAGE-NAME";

const { something } = useLibrary({
argument1: "something",
argument2: "something else",
});
```
A simple React hook for listening to custom keyboard events. This hook is also SSR safe and does not break when used without `window` existing.

## Installation

Install this package with `npm`.

```bash
npm i @phntms/PACKAGE-NAME
npm i -D @phntms/use-key
```

## Usage

Example 1 description.

```JSX
import React from 'react';
import useLibrary from '@phntms/PACKAGE-NAME';

const SomeExample = () = {
const { something } = useApi({
argument1: "something",
argument2: "something else",
});

return (
<>
<h1>Result</h2>
<p>{something}</p>
</>
);
}
To listen to a single key:

```jsx
import useKey from "@phntms/use-key";

useKey("Escape", (pressed: boolean) => {
if (pressed) // Do something on "Escape"...
});
```

Example 2 description.

```JSX
import React from 'react';
import useLibrary from '@phntms/PACKAGE-NAME';

const SomeExample2 = () = {
const { something } = useApi({
argument1: "something",
argument2: "something else",
});

return (
<>
<h1>Result</h2>
<p>{something}</p>
</>
);
}
To listen to key modifiers:

```jsx
import useKey from "@phntms/use-key";

useKey("g", (pressed: boolean, event: KeyboardEvent) => {
if (pressed && event.ctrlKey) // Do something on "Ctrl + G"...
});
```

## API

### Input
The hook uses [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) under the hood. This means using the `onChange` event, you can get the state of modifier keys such as Shift as well as the keyboard locale and layout.

- `argument1` : Required - Description of argument.
- `argument2` : Optional - Description of argument.
## Contributing

### Output
Want to get involved, or found an issue? Please contribute using the GitHub Flow. Create a branch, add commits, and open a Pull Request or submit a new issue.

- `something`: Description of output.
Please read `CONTRIBUTING` for details on our `CODE_OF_CONDUCT`, and the process for submitting pull requests to us!

[npm-image]: https://img.shields.io/npm/v/@phntms/PACKAGE-NAME.svg?style=flat-square&logo=react
[npm-url]: https://npmjs.org/package/@phntms/PACKAGE-NAME
[npm-downloads-image]: https://img.shields.io/npm/dm/@phntms/PACKAGE-NAME.svg
[npm-downloads-url]: https://npmcharts.com/compare/@phntms/PACKAGE-NAME?minimal=true
[ci-image]: https://github.com/phantomstudios/PACKAGE-NAME/workflows/test/badge.svg
[ci-url]: https://github.com/phantomstudios/PACKAGE-NAME/actions
[npm-image]: https://img.shields.io/npm/v/@phntms/use-key.svg?style=flat-square&logo=react
[npm-url]: https://npmjs.org/package/@phntms/use-key
[npm-downloads-image]: https://img.shields.io/npm/dm/@phntms/use-key.svg
[npm-downloads-url]: https://npmcharts.com/compare/@phntms/use-key?minimal=true
[ci-image]: https://github.com/phantomstudios/use-key/workflows/test/badge.svg
[ci-url]: https://github.com/phantomstudios/use-key/actions
6 changes: 3 additions & 3 deletions SUPPORT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PACKAGE-NAME Support
# use-key Support

For _questions_ on how to use `PACKAGE-NAME` or what went wrong when you tried something, our primary resource is by opening a
[GitHub Issue](https://github.com/phantomstudios/PACKAGE-NAME/issues), where you can get help from developers.
For _questions_ on how to use `use-key` or what went wrong when you tried something, our primary resource is by opening a
[GitHub Issue](https://github.com/phantomstudios/use-key/issues), where you can get help from developers.
Loading

0 comments on commit 88b908c

Please sign in to comment.