Sending keydown, keypress on type in nightmare.js
<p>Type method in nightmare.js assigns the text to input control's value property. Due to this implementation keydown,keypress event doesn't get triggered on the on the page your are trying to scrape. Any way to send keydown event after 'type'?</p>

<p><strong>Edit 1-</strong></p>

<p>Here is an example to send event using jQuery, which doesn't work either-</p>

<pre><code>var Nightmare = require('nightmare');
var vo = require('vo');
var nightmare = Nightmare();

vo(run)(function(err, result) {
  if (err) throw err;
});

function *run() {

  var title = yield nightmare
    .goto('http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes')
    .type('#txtChar','\n')
    .evaluate(function() {
      var e = $.Event( "keypress", { which: 13 } );
        $('#txtChar').trigger(e);
        return "Key you pressed is : " + $('#txtChar').val();
    });

  yield  nightmare.pdf('type.pdf');
  setTimeout(function () {
    console.log( ' ' + title);
    nightmare.end();
    process.exit();
  },2000);
}
</code></pre>

<p><strong>Edit 2-</strong></p>

<p>Using unicode equivalent of keys as parameter to type method invokes attached events somehow, not exactly sure how this hack works, but it works!</p>

<p>Here is the working example-</p>

<pre><code>var Nightmare = require('nightmare');
var vo = require('vo');
var nightmare = Nightmare();

vo(run)(function(err, result) {
  if (err) throw err;
});

function *run() {

  var title = yield nightmare
    .goto('http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes')
    .type('#txtChar','1') //so we have focus on textbox
    .type('document', '\u000d')
    .evaluate(function() {
        return "Key you pressed is : " + $('#txtChar').val();
    });

  yield  nightmare.pdf('type.pdf');
  setTimeout(function () {
    console.log( ' ' + title);
    nightmare.end();
    process.exit();
  },2000);
}
</code></pre>