Skip to content

Commit 81299da

Browse files
jakstKent C. Dodds
authored and
Kent C. Dodds
committed
docs: document firing keyboard events (testing-library#154)
<!-- Thanks for your interest in the project. Bugs filed and PRs submitted are appreciated! Please make sure that you are familiar with and follow the Code of Conduct for this project (found in the CODE_OF_CONDUCT.md file). Also, please make sure you're familiar with and follow the instructions in the contributing guidelines (found in the CONTRIBUTING.md file). If you're new to contributing to open source projects, you might find this free video course helpful: http://kcd.im/pull-request Please fill out the information below to expedite the review and (hopefully) merge of your pull request! --> <!-- What changes are being made? (What feature/bug is being fixed here?) --> **What**: Vague documentation (issue testing-library#153 ) <!-- Why are these changes necessary? --> **Why**: To clarify usage to users <!-- How were these changes implemented? --> **How**: Added documentation <!-- Have you done all of these things? --> **Checklist**: <!-- add "N/A" to the end of each line that's irrelevant to your changes --> <!-- to check an item, place an "x" in the box like so: "- [x] Documentation" --> - [x] Documentation N/A - [ ] Tests N/A - [x] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? --> - [ ] Added myself to contributors table <!-- this is optional, see the contributing guidelines for instructions --> <!-- feel free to add additional comments -->
1 parent b8752fb commit 81299da

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,14 @@ fireEvent.change(getByLabelText(/picture/i), {
665665
})
666666
```
667667

668+
**Keyboard events**: There are three event types related to keyboard input - `keyPress`, `keyDown`, and `keyUp`. When firing these you need to reference an element in the DOM and the key you want to fire.
669+
670+
```javascript
671+
fireEvent.keyDown(domNode, { key: 'Enter', code: 13 })
672+
```
673+
674+
You can find out which key code to use at [https://keycode.info/](https://keycode.info/).
675+
668676
### `getNodeText`
669677

670678
```typescript

0 commit comments

Comments
 (0)