J
Jake Barnes
I'm researching the Enter key. This is for an Ajax chat application.
The designer tells me that she wants people to be able to submit text
simply by hitting the Enter key. She wants this to happen even if
people still have the cursor inside the textarea where they have just
been typing.
I started researching this and came upon this post by Michael Winter,
from 2004:
http://groups.google.com/group/comp...trigger+the+enter+key&rnum=1#ed9e99418caa29f4
"If the button has focus, pressing enter will invoke an onclick event.
If some other control (in a form) has focus, the form's submit button
will receive the event. As I see it, if you do want to invoke an event
on an arbitrary control, you'll have to handle the onkeydown event on
*every* control that might be active when Enter is pressed and fire
the event yourself. That's a lot of work."
Huh. Well, before I run off and do a bunch of work, let me clarify
this. If I just want the one textarea to trigger an event when the
Enter key is hit, I only need to override the event handling for that
one textarea, yes?
How does one capture this? Do I examine onkeydown to see if the Enter
key is the key being pushed down?
The designer tells me that she wants people to be able to submit text
simply by hitting the Enter key. She wants this to happen even if
people still have the cursor inside the textarea where they have just
been typing.
I started researching this and came upon this post by Michael Winter,
from 2004:
http://groups.google.com/group/comp...trigger+the+enter+key&rnum=1#ed9e99418caa29f4
"If the button has focus, pressing enter will invoke an onclick event.
If some other control (in a form) has focus, the form's submit button
will receive the event. As I see it, if you do want to invoke an event
on an arbitrary control, you'll have to handle the onkeydown event on
*every* control that might be active when Enter is pressed and fire
the event yourself. That's a lot of work."
Huh. Well, before I run off and do a bunch of work, let me clarify
this. If I just want the one textarea to trigger an event when the
Enter key is hit, I only need to override the event handling for that
one textarea, yes?
How does one capture this? Do I examine onkeydown to see if the Enter
key is the key being pushed down?