Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Make tap fire on spacebar for non-input elements
Browse files Browse the repository at this point in the history
- Fires up keyup
- Addresses #12
  • Loading branch information
dfreedm committed Aug 23, 2013
1 parent 4128d41 commit e237b9f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
'pointerdown',
'pointermove',
'pointerup',
'pointercancel'
'pointercancel',
'keyup'
],
pointerdown: function(inEvent) {
if (inEvent.isPrimary && !inEvent.tapPrevented) {
Expand Down Expand Up @@ -68,6 +69,21 @@
pointercancel: function(inEvent) {
pointermap.delete(inEvent.pointerId);
},
keyup: function(inEvent) {
var code = inEvent.keyCode;
// 32 == spacebar
if (code === 32) {
var t = inEvent.target;
if (!(t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement)) {
dispatcher.dispatchEvent(dispatcher.makeEvent('tap', {
x: 0,
y: 0,
detail: 0,
pointerType: 'unavailable'
}), t);
}
}
},
preventTap: function(inPointerId) {
pointermap.delete(inPointerId);
}
Expand Down

0 comments on commit e237b9f

Please sign in to comment.