简体   繁体   中英

How to do keypress of “@” in CasperJS

I am trying to do the following:

page.sendEvent('keypress', page.event.key['N'], null, null, 0)
page.sendEvent('keypress', page.event.key['@'], null, null, 0)

But the @ symbol is not working. How would I enter in @ in the above?

Here is the event I am trying to use: http://phantomjs.org/api/webpage/method/send-event.html

"@" and "N" are normal characters on the keyboard so you can simply pass them as string:

page.sendEvent('keypress', 'N');
page.sendEvent('keypress', '@');

or even

page.sendEvent('keypress', 'N@');

Since you're not setting any modifier, you can remove the optional values of sendEvent() .

Have you tried:

// https://github.com/ariya/phantomjs/commit/cab2635e66d74b7e665c44400b8b20a8f225153a#diff-e52366857ac302b6d40c78a058758a0aR358
page.sendEvent('keypress', page.event.key['At'], null, null, 0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM