Created
July 1, 2016 08:49
-
-
Save jbuncle/90701499a52e2081a6bd59f62947f580 to your computer and use it in GitHub Desktop.
Basic jQuery function for handling enter key being hit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Basic jQuery function for handling enter key being hit. | |
* | |
* @returns jQuery | |
*/ | |
$.fn.onEnterKeypress = function (callback) { | |
return $(this).keypress(function (evt) { | |
// Check for enter key | |
if (evt.which === 13) { | |
// Invoke callback | |
callback.call(this, evt); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment