JS/jquery problem

hey guys,

I have a form with a textarea and want to submit it by pressing the enter key. But by holding down shift and pressing enter it should just add a new line (\n).

Okay here is my html:

<form>
		<textarea name="text" id="text_feld" autofocus="autofocus" class="commentarea"></textarea>
		<input name="submit" id="submit" type="submit" value="Submit">
		<input type="hidden" name="user" id="user" value="' . $session['username'] . '">
</form>

And here my JS

$(document).ready(function() {
    $('.commentarea').keydown(function(event) {
      if (event.keyCode == 13 && !evt.shiftKey) {
      $.ajax({
      type: 'post',
      url: 'eingabe.php',
      data: $('form').serialize(),
			success: $("#text_feld").val(""),
      });
      }
    });
});

Okay. with this code “shift + enter” and “enter” do the same => add new line (no submit)

if i change

if (event.keyCode == 13 && !evt.shiftKey) {

to

if (event.keyCode == 13) {

the form submits by pressing “enter” and by pressing “shift + enter”

never coded soemthing with JS before so im having a hard time with it :confused:

As anybody ideas how to solve this?

You have a typo in the line above - the second condition should be !event.shiftKey