Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added button click and keypress event (only works in FF for now)

  • Loading branch information...
commit 4fa61b27e0c7a277ee63bafc623f34037a779a57 1 parent 2d0b13d
@davglass authored
Showing with 28 additions and 4 deletions.
  1. +13 −0 src/capture.js
  2. +15 −4 tests/index.html
View
13 src/capture.js
@@ -40,6 +40,16 @@
YAHOO.util.UserAction.mouseup(tar, e);
YAHOO.util.UserAction.click(tar, e);
},
+ _handleKeyPress: function(e) {
+ var tar = Event.getTarget(e);
+
+ try {
+ tar.focus();
+ } catch (e) {};
+ YAHOO.util.UserAction.keyup(tar, e);
+ YAHOO.util.UserAction.keydown(tar, e);
+ YAHOO.util.UserAction.keypress(tar, e);
+ },
start: function() {
this._started = (new Date()).getTime();
this._stopped = null;
@@ -57,6 +67,9 @@
for (var i = 0; i < f.length; i++) {
index = (f[i][3] - this._started);
switch (f[i][1]) {
+ case 'keypress':
+ method = this._handleKeyPress;
+ break;
case 'click':
method = this._handleClick;
break;
View
19 tests/index.html
@@ -22,8 +22,10 @@
<button id="start">Start</button> - <button id="stop" disabled>Stop</button> - <button id="play" disabled>Play</button>
-<p>Test <a href="#" id="test1">Test Link #1 Click</a></p>
-<p>Test <a href="#" id="test2">Test Link #2 Click</a></p>
+<p>Test #1: <a href="#" id="test1">Test Link #1 Click</a></p>
+<p>Test #2: <a href="#" id="test2">Test Link #2 Click</a></p>
+<p>Test #3: <button id="test3">Test Button #1 Click</button></p>
+<p>Test #4: <input type="text" value="" size="20" id="test4"></p>
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.6.0/build/yahoo-dom-event/yahoo-dom-event.js&2.6.0/build/logger/logger-min.js&2.6.0/build/yuitest/yuitest-min.js"></script>
@@ -38,12 +40,21 @@
Event.on('test1', 'click', function(e) {
Event.stopEvent(e);
- console.log('Link #1 Clicked..');
+ //console.log('Link #1 Clicked..');
});
Event.on('test2', 'click', function(e) {
Event.stopEvent(e);
- console.log('Link #2 Clicked..');
+ //console.log('Link #2 Clicked..');
+ });
+
+ Event.on('test3', 'click', function(e) {
+ Event.stopEvent(e);
+ //console.log('Button #1 Clicked..');
+ });
+
+ Event.on('test4', 'keypress', function(e) {
+ //console.log('Input keypress..', e);
});
capture = new YAHOO.util.Capture();
Please sign in to comment.
Something went wrong with that request. Please try again.