enzymejs / enzymejs/enzyme

Unable to simulate keyboard events

Open
#441 34 comments 22 reactions 0 assignees View on GitHub
Need More Information
Dominant language
JavaScript
Stars
19.8k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

**Problem**

I'm truing to simulate keyboard events with enzyme but I couldn't find a single line of documentation or code example where keyboard events are implemented. I've tried using

```
wrapper.find(".myclass").simulate("keyDown", {
target: {
keyCode: 40,
which: 40,
key: "down arrow"
}
});
```

and

```
wrapper.find(".myclass").simulate("keyDown", {
keyCode: 40,
which: 40,
key: "down arrow"

});
```

I've also tried using other types of casing on the event name and key names but nothing worked.

While there's no error using any of the two examples I've mentioned the output just isn't the expected and using `TestUtils.Simulate.keyDown(searchInput, { keyCode: 40 });` all works as expected.
Am I not using the correct syntax?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.