“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay...”

Rob Lacey (contact@robl.me)
Senior Software Engineer, Brighton, UK

disable enter key in jQuery

Fed up of accidentally submitting forms with the enter key, of course you probably need to be able to do newlines in text areas.

$("body").keypress(function(e) {
  if (e.which == 13 && !$(e.target).is("textarea")) {
    return false;
  }
});

Or if you want to be more specific.

$('form input[type="submit"]').keypress(function(e) {
  if (e.which == 13) {
    return false;
  }
});