Catching 'Enter' key with javascript. was: [Seaside] Re: Comparison of Aida/Web, Seaside and Iliad web frameworks

Paul DeBruicker pdebruic at gmail.com
Wed Jun 22 15:24:02 UTC 2011


On 06/22/2011 09:31 AM, H. Hirzel wrote:
> For example I would love to have tables where people can
> enter rows and terminate them with the 'Enter' key.

I don't know if this is what you have in mind but you can catch the 
'Enter' key press in a text input and substitute your own behavior using 
javascript.  Here is how I do it using jQuery:

(function ($) {
     $.fn.catchEnter = function () {
         $('#search').keydown(function (e) {
             if (e.keyCode == 13) {
                 e.preventDefault();
                 $('#searchButton').click();
             }
         });
     };
})(jQuery);

so when the cursor is in the #search textInput if the user presses 
'Enter' the page refresh action is blocked and the search button's click 
event is triggered.




More information about the seaside mailing list