Test keydown event in AngularJS with Jasmine and PhantomJS
<p>I tried to implement solution from <a href="https://stackoverflow.com/a/23700583/2677738">here</a> with this function, but this doesn't work, everytime I have <code>oEvent.keyCode = 0</code></p>

<p>In unit tests keydown event are triggered, but I can't test if specific key are pressed. </p>

<p><strong>SOLUTION:</strong><br>
This worked for me with PhantomJS 1.9.8</p>

<pre><code>function simulateKeydownEvent(element, keyCode) {
    var event = document.createEvent("Events");
    event.initEvent("keydown", true, true);
    event.keyCode = keyCode;
    element.dispatchEvent(event);
}
</code></pre>