Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(browserTrigger): key events
Browse files Browse the repository at this point in the history
Support for key events like keypress, keyup or keydown.
Gonzalo Ruiz de Villa committed Sep 10, 2015
1 parent 00ee090 commit be609f8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ngScenario/browserTrigger.js
Original file line number Diff line number Diff line change
@@ -79,6 +79,17 @@
}
} else if (/touch/.test(eventType) && supportsTouchEvents()) {
evnt = createTouchEvent(element, eventType, x, y);
} else if (/key/.test(eventType)) {
evnt = document.createEvent('Events');
evnt.initEvent(eventType, eventData.bubbles, eventData.canceable);
evnt.view = window;
evnt.ctrlKey = pressed('ctrl');
evnt.altKey = pressed('alt');
evnt.shiftKey = pressed('shift');
evnt.metaKey = pressed('meta');
evnt.keyCode = eventData.keyCode;
evnt.charCode = eventData.charCode;
evnt.which = eventData.which;
} else {
evnt = document.createEvent('MouseEvents');
x = x || 0;

0 comments on commit be609f8

Please sign in to comment.