David542
David542

Reputation: 110502

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

Upvotes: 1

Views: 303

Answers (2)

Artjom B.
Artjom B.

Reputation: 61952

"@" 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().

Upvotes: 2

Andreas Louv
Andreas Louv

Reputation: 47137

Have you tried:

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

Upvotes: 0

Related Questions