//...
<a href="#" id="foo-link">Foo</a>
<script type="text/javascript">
$('#foo-link').click(function(e) {
//...
}
</script>
//...
Using jQuery on a HTML page, the above defined click
handler is executed
- when the user clicks it and
- when the user navigates to it via Tab and hits Enter
(At least in Firefox) there seems to be no difference between the click events passed to the handler - the original key event 'magically' translates to a click event.
Is there a way to differentiate between those two cases?
To give more details on why I need to treat those two cases differently: in my particular case the click handler sets the focus to a text input field. This text input field has a keyup
event handler registered which sends an AJAX request. When the click handler was triggered after the user hitting Enter on the link, the keyup
event is received by the now focused text input field and the AJAX request is sent mistakenly.