If you have multiple forms on the page, you might have to implement such a solution, especially if focus often is not on one of the form elements of the default form (well, he is what I remember from having to do something like this over 4 years ago).