It's been my experience that listening for keycodes in js can be a bit hairy. If you have a bunch of inputs, it's probably semantic to wrap them in a form (the div too if you like), then you could take advantage of the on built-in event listener but just prevent the actual form submission:
$('#myForm').submit(function(e){ e.preventDefault(); doSomething(); }); On Thu, Jun 26, 2008 at 1:45 PM, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote: > > Thanks for your replies. I have a follow up question. Let's say I > have a bunch of inputs, type="text" within a div with id="myDiv". How > do trigger an action if someone presses enter within one of those text > fields? This would not be a form submission necessarily. > > - Dave > > > On Jun 26, 5:25 am, tlob <[EMAIL PROTECTED]> wrote: > > A page is read without css? Hmmm I think that is really really really > > rare.... Even more rare than a browser without js turned on. Thats > > only really really rare ;-) > > > > Or what do you mean? > > > > instead of moving it away, why not css display:none;? Does this brake > > the submit? > > cheers > > tl > > > > On Jun 26, 10:22 am, Steen Nielsen <[EMAIL PROTECTED]> wrote: > > > > > > > > > You need to insert a submit button in the form to get it working.. > > > <input type="submit"> > > > > > if you don't want to show the button you can always hide it using CSS. > > > I usually just positioning it -9000px to the left, that way it won't > > > show up, but if the page is read without CSS, it will be shown > > > correctly with a submit button > > > > > On Jun 26, 6:20 am, "[EMAIL PROTECTED]" > > > > > <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > > > I have a form, with id="myForm", with a number of text fields (input > > > > with type="text"). How do I cause a form submission by pressing > enter > > > > in any of those form fields? > > > > > > Thanks, - Dave- Hide quoted text - > > > > - Show quoted text - >