How to press Enter button in Puppeteer and JavaScript?

Sometimes, we want to press Enter button in Puppeteer and JavaScript.

In this article, we’ll look at how to press Enter button in Puppeteer and JavaScript.

How to press Enter button in Puppeteer and JavaScript?

To press Enter button in Puppeteer and JavaScript, we use the page.keyboard.press method.

For instance, we write

await page.keyboard.press("Enter");
await page.keyboard.press("NumpadEnter");

to call press with 'Enter' to press the enter key.

And we call press with 'NumpadEnter' to press the numpad enter key.

Conclusion

To press Enter button in Puppeteer and JavaScript, we use the page.keyboard.press method.