Content-Length: 260034 | pFad | http://github.com/pobch/testing-library-docs/commit/dfed1816f6af130a30b22329f4824d75adb9f291

72 Update events doc for event.which usage on keyboard events (#262) · pobch/testing-library-docs@dfed181 · GitHub
Skip to content

Commit dfed181

Browse files
vernonkKent C. Dodds
authored andcommitted
Update events doc for event.which usage on keyboard events (testing-library#262)
1 parent 8a6c0d0 commit dfed181

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/dom-testing-library/api-events.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ fireEvent.keyDown(domNode, { key: 'Enter', code: 13 })
7070
// will Fire an KeyboardEvent with charCode = 0
7171
fireEvent.keyDown(domNode, { key: 'Enter', code: 13 })
7272

73+
// If using event.which, be sure to set the keyCode or it will be fallback to 0
74+
// will Fire a KeyboardEvent with expected which = 13
75+
fireEvent.keyDown(domNode, { key: 'Enter', keyCode: 13 })
76+
7377
// will Fire an KeyboardEvent with charCode = 65
7478
fireEvent.keyDown(domNode, { key: 'A', code: 65, charCode: 65 })
7579
```

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/pobch/testing-library-docs/commit/dfed1816f6af130a30b22329f4824d75adb9f291

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy