-
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.
* Initial commit * Tweak * Remove test workflows * Add output * Add key types * Remove key types
- Loading branch information
Showing
10 changed files
with
12,227 additions
and
112 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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 +1 @@ | ||
* @digitaljohn | ||
* @paulomfj @digitaljohn |
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
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
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
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,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 |
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,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. |
Oops, something went wrong.