Rob, Is this some sort of autocomplete text box or is it a select input? James
________________________________ From: jquery-en@googlegroups.com on behalf of rob303 Sent: Tue 20/01/2009 13:44 To: jQuery (English) Subject: [jQuery] Identify last keeypess Hi, I've been searching the web for an answer to this but haven't been able to find one. I have a form which is using an image as it's submit button and I want users to be able to submit the form by pressing enter. Simple enough: // submit the login form if the user hits enter $('.login_input').keypress(function(event) { if(event.keyCode == 13) { $('#login').submit(); } }); That works fine. However, if the user is presented with a list of options for the text input by their browser and they use the up and down arrows keys to highlight, then enter to select an option the form gets submitted. Not ideal! So, my question is how can I identify the last key press before the user hits enter? Ideally my logic will be something like: $('.login_input').keypress(function(event) { if(LAST KEYPRESS IS NOT UP OR DOWN ARROW) { if(event.keyCode == 13) { $('#login').submit(); } } }); Hopefully, that makes sense! Many thanks in advance for any help. Rob. -------------------------------------------------------------------- This e-mail is intended solely for the addressee and is strictly confidential; if you are not the addressee please destroy the message and all copies. Any opinion or information contained in this email or its attachments that does not relate to the business of Kainos is personal to the sender and is not given by or endorsed by Kainos. Kainos is the trading name of Kainos Software Limited, registered in Northern Ireland under company number: NI19370, having its registered offices at: Kainos House, 4-6 Upper Crescent, Belfast, BT7 1NT, Northern Ireland. Registered in the UK for VAT under number: 454598802 and registered in Ireland for VAT under number: 9950340E. This email has been scanned for all known viruses by MessageLabs but is not guaranteed to be virus free; further terms and conditions may be found on our website - www.kainos.com