ariya/phantomjs — pull request #290 by milianw (2012-07-04 11:10:55+00:00)
Title: Support for keyboard events

This is based off https://github.com/ariya/phantomjs/pull/287 , see that merge request for more information and discussion.

The changes proposed here allow us to do things like:

page.sendEvent('keydown', phantom.keys.Escape);
page.sendEvent('keyup', phantom.keys.Escape);
// same as the above
page.sendEvent('keypress', phantom.keys.Escape);
// also works with chars
page.sendEvent('keypress', "a");
// and even with strings
page.sendEvent('keypress', "adsfsadf");

Personally I think this patchset is ready to be merged. It lays the cornerstone for future work, as mentioned in the merge request above, namely:

- improved events API, maybe following the one that jQuery uses
- simplified focusing of elements, or generally a simplified way of sending events to arbitrary elements on the page