Page 1 of 1

On Enter

Posted: Fri Dec 16, 2005 2:09 pm
by hawleyjr
I'm creating a chat application. If the user hits the "Enter" key while in the message textarea I want to submit the form. However, if the user hits "SHIFT-ENTER" I want it to do a soft return and not submit the form.

I know there is a key capture function I'm just not sure how to do the SHIFT-ENTER part.

Thanks.

Posted: Fri Dec 16, 2005 5:58 pm
by feyd
viewtopic.php?t=37059

may be of interest.

Posted: Fri Dec 16, 2005 7:24 pm
by Chris Corbyn
Hehehe.... check my code snippet in here for write_r(). Ermm... actually don't that's just how I discovered this ;)

Here's how to do it:

1. Capture all keypress events
2. Check if keycode == <whatever> the enter keycode is
3. Look if "shiftKey" is set (i.e shift key was held down at the same time)

This info comes out in the window.Event object :D

Posted: Fri Dec 16, 2005 8:21 pm
by hawleyjr
feyd wrote:viewtopic.php?t=37059

may be of interest.
Feyd that code you posted is awesome.

THX