$(document).keypress(function(e) {
if(e.ctrlKey && e.which == 13) {
$('#myForm').submit();
}
});
or
$('#myForm').keypress(function(e) {
if(e.ctrlKey && e.which == 13) {
$(this).submit();
}
});
- Richard
On Thu, Dec 17, 2009 at 7:40 PM, Andre Polykanine <[email protected]> wrote:
> Hello Mike and all,
>
> Sorry, I also have a question about keypresses.
> I need a form to be submitted by pressing Ctrl+Enter. How do I manage
> to do that?
> Thanks!
>
> --
> With best regards from Ukraine,
> Andre
> Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
> jabber.org
> Yahoo! messenger: andre.polykanine; ICQ: 191749952
> Twitter: m_elensule
>
> ----- Original message -----
> From: Mean Mike <[email protected]>
> To: jQuery (English) <[email protected]>
> Date: Thursday, December 17, 2009, 9:06:36 PM
> Subject: [jQuery] Re: What is the event when a user presses the enter key
> anywhere on the page?
>
> keypress
>
> $(document).keypress(function(e) {
> if ((e.which && e.which == 13) ||
> (e.keyCode &&e.keyCode == 13))
> {
> // do something
> }
> });
> mean mike
> On Dec 17, 2:03 pm, "[email protected]"
> <[email protected]> wrote:
> > Hi,
> >
> > I would like to capture the event of pressing enter anywhere on the
> > page, even if the focus of the mouse cursor is not on a text field.
> > What event/element am I looking at?
> >
> > Thanks, - Dave
>
>