-
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 * Remove getting_started * Write tests * Tweak * Add keywords * Rename * Rest of rename * Replace use-key-event with use-key-down * Rename 'use-key-down' to 'use-keydown' * Tweaks * Force rename * Revert * Fix * Create tests for bug flagged * Fix plural * Remove empty line * Tweak * Add @buildinams/lint
- Loading branch information
Showing
12 changed files
with
1,418 additions
and
429 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 |
---|---|---|
@@ -1,15 +1,3 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["prettier", "unused-imports", "simple-import-sort"], | ||
"extends": [ | ||
"plugin:react/recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"rules": { | ||
"react/react-in-jsx-scope": "off", | ||
"unused-imports/no-unused-imports": "error", | ||
"simple-import-sort/exports": "error", | ||
"simple-import-sort/imports": "error" | ||
} | ||
"extends": "./node_modules/@buildinams/lint/react-typescript" | ||
} |
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 |
---|---|---|
@@ -1,81 +1,56 @@ | ||
# PACKAGE-NAME | ||
# use-keydown | ||
|
||
[![NPM version][npm-image]][npm-url] | ||
[![Actions Status][ci-image]][ci-url] | ||
[![PR Welcome][npm-downloads-image]][npm-downloads-url] | ||
|
||
PACKAGE-DESCRIPTION | ||
React hook for listening to custom `keydown` [events](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code). | ||
|
||
## Introduction | ||
|
||
Package introduction, couple of paragraphs. | ||
This hook optimizes keyboard event handling by utilizing a single window `keydown` event listener for all instances of the hook, resulting in a more streamlined and efficient process. | ||
|
||
```typescript | ||
import useHook from "@buildinams/PACKAGE-NAME"; | ||
|
||
const baz = useHook({ | ||
foo: "something", | ||
bar: "something else", | ||
}); | ||
``` | ||
This library is also SSR safe, and only runs on the client. | ||
|
||
## Installation | ||
|
||
Install this package with `npm`. | ||
|
||
```bash | ||
npm i @buildinams/PACKAGE-NAME | ||
npm i @buildinams/use-keydown | ||
``` | ||
|
||
## Usage | ||
|
||
Example 1 description. | ||
To listen to a single key: | ||
|
||
```tsx | ||
import React from 'react'; | ||
import useHook from '@buildinams/PACKAGE-NAME'; | ||
|
||
const SomeExample = () = { | ||
const baz = useHook({ | ||
foo: "something", | ||
bar: "something else", | ||
}); | ||
|
||
return ( | ||
<p>{baz}</p> | ||
); | ||
} | ||
``` | ||
|
||
## API | ||
|
||
### Input | ||
import useKeydown from "@buildinams/use-keydown"; | ||
|
||
- `foo`: Required - Description of argument. | ||
- `baz`: Optional - Description of argument. | ||
|
||
### Input as a table | ||
useKeydown("Escape", () => {}); // Do something on "Escape"... | ||
``` | ||
|
||
| Property | Type | Required | Notes | | ||
| -------- | ------ | -------- | ------------------------ | | ||
| **foo** | string | **Yes** | Description of argument. | | ||
| **baz** | string | No | Description of argument. | | ||
To listen to key modifiers: | ||
|
||
### Output | ||
```tsx | ||
import useKeydown from "@buildinams/use-keydown"; | ||
|
||
- `baz`: Description of output. | ||
useKeydown("KeyG", (event: KeyboardEvent) => { | ||
if (event.ctrlKey) // Do something on "Ctrl + G"... | ||
}); | ||
``` | ||
|
||
## Requirements | ||
|
||
This library requires a minimum React version of `18.0.0`. | ||
|
||
## Requests and Contributing | ||
|
||
Found an issue? Want a new feature? Get involved! Please contribute using our guideline [here](https://github.com/buildinamsterdam/PACKAGE-NAME/blob/main/CONTRIBUTING.md). | ||
Found an issue? Want a new feature? Get involved! Please contribute using our guideline [here](https://github.com/buildinamsterdam/use-keydown/blob/main/CONTRIBUTING.md). | ||
|
||
[npm-image]: https://img.shields.io/npm/v/@buildinams/PACKAGE-NAME.svg?style=flat-square&logo=react | ||
[npm-url]: https://npmjs.org/package/@buildinams/PACKAGE-NAME | ||
[ci-image]: https://github.com/buildinamsterdam/PACKAGE-NAME/actions/workflows/test.yml/badge.svg | ||
[ci-url]: https://github.com/buildinamsterdam/PACKAGE-NAME/actions | ||
[npm-downloads-image]: https://img.shields.io/npm/dm/@buildinams/PACKAGE-NAME.svg | ||
[npm-downloads-url]: https://npmcharts.com/compare/@buildinams/PACKAGE-NAME?minimal=true | ||
[npm-image]: https://img.shields.io/npm/v/@buildinams/use-keydown.svg?style=flat-square&logo=react | ||
[npm-url]: https://npmjs.org/package/@buildinams/use-keydown | ||
[ci-image]: https://github.com/buildinamsterdam/use-keydown/actions/workflows/test.yml/badge.svg | ||
[ci-url]: https://github.com/buildinamsterdam/use-keydown/actions | ||
[npm-downloads-image]: https://img.shields.io/npm/dm/@buildinams/use-keydown.svg | ||
[npm-downloads-url]: https://npmcharts.com/compare/@buildinams/use-keydown?minimal=true |
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
Oops, something went wrong.