在木偶操纵者中按Enter键 [英] Pressing Enter button in puppeteer

查看:78
本文介绍了在木偶操纵者中按Enter键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在木偶操作中按Enter键似乎没有任何效果。但是,当我按下其他键时,它会做它应该做的事情。
这样可行:

Pressing enter in puppeteer doesn't seem to have any effect. However, when I press other keys, it does what it should. This works:

await page.press('ArrowLeft');

这不是:

await page.press('Enter');

这是输入的样子:

有任何想法吗?

编辑:我'我也尝试过page.keyboard.down& page.keyboard.up确定。

I've also tried page.keyboard.down & page.keyboard.up to be sure.

推荐答案

await page.type(String.fromCharCode(13));

使用这个网站我注意到 page.type 在输入之前发送 输入事件,但 page.press 没有。这可能是一个错误,但幸运的是发送回车键码(13)似乎有效,所以我们现在可以解决它。

Using this site I noticed that page.type dispatches beforeinput and input events, but page.press doesn't. This is probably a bug, but fortunately sending the enter keycode (13) seems to work, so we can work around it for now.

这篇关于在木偶操纵者中按Enter键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆