ngryman / jquery.finger

:v: jQuery touch & gestures, fingers in the nose.
https://ngryman.sh/jquery.finger/
MIT License
423 stars 66 forks source link

Keyboard support? #27

Closed chrislachance closed 9 years ago

chrislachance commented 9 years ago

Thanks for this, it's working great so far! I was wondering if you had any plans to add the keyboard's enter key as a 'tap' action as well? The default .click function in jQuery seems to support it, and it would be nice to have one event for all input types. Thanks for considering!

ngryman commented 9 years ago

Hi,

Clicking or pressing return key are really two different events that should not be merged in any kind of way. I can confirm you that jQuery's click is not triggered when you press return and vice versa. For your needs it probably is useful, but for others it would be unclear and weird.

That said, if for any reason you need a tap event to be triggered when you press return, you could do something like this:

$('.selector').on('keypress', function(e) {
  if (13 === e.keyCode)
    $('.other-selector').trigger('tap');
});