I am writing tests for an AngularJS directive which fires events of a when certain keys are pressed. It all works fine per my manual testing. I
Adding to @MarcoL answer, I'd like to point out for future readers who might stumble on this question, that the methods initKeyboardEvent and initKeyEvent are deprecated methods, and should no longer be used. See here and here.
Instead as the MDN docs suggested, events should be created via their respective constructor.