Skip to content

Instantly share code, notes, and snippets.

@michaelbramwell
Created December 19, 2012 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelbramwell/4334260 to your computer and use it in GitHub Desktop.
Save michaelbramwell/4334260 to your computer and use it in GitHub Desktop.
jQuery func enter key
$.fn.enterKey = function (fnc) {
/// <summary>Power Search: Enter Key press</summary>
/// http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
return this.each(function () {
$(this).keypress(function (ev) {
var keycode = (ev.keyCode ? ev.keyCode : ev.which);
if (keycode == 13) {
fnc.call(this, ev);
}
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment