Can't fire browser behaviours with keyevent

I am using PhantomJS 2.1.1 to send the Enter keycode to a page on a client-side site built with VAADIN for testing. The page is never submitted. When I added the listener to output what the key code was, it showed 0 instead of 13

Am I doing something wrong?

document.getElementsByTagName("input")[1]
.focus();
document.getElementsByTagName("input")[1]
.value = "123456";
document.addEventListener('keydown', function(e){
   console.log("key pressed was: " + e.keyCode);
});
//SEND RETURN KEY TO PAGE
var ev = document.createEvent('KeyboardEvent');
ev.initKeyboardEvent( 'keydown', true, true, window, false, false, false, false, 13, 0);
document.getElementsByTagName("input")[1]
.dispatchEvent(ev);

The PhantomJS SendEvent doesn’t work either on the page. It too returns 0

page.sendEvent('keypress', page.event.key.ENTER);

There is no form tag to
.submit().
In a standard Firefox application using ScratchPad, I
CAN
use the dispatchEvent and it works fine.